Skip to content

Commit 91c62e0

Browse files
Potential fix for code scanning alert no. 38: Query built from user-controlled sources
Fix SQL in Benchmark00026 via JDBCtemplate.queryForRowSet() Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 034a7ba commit 91c62e0

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/main/java/org/owasp/benchmark/testcode/Benchmark00026.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ public void doPost(HttpServletRequest request, HttpServletResponse response)
4444
String param = request.getParameter("Benchmark00026");
4545
if (param == null) param = "";
4646

47-
String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + param + "'";
47+
String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD=?";
4848
try {
4949
org.springframework.jdbc.support.rowset.SqlRowSet results =
50-
org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForRowSet(sql);
50+
org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForRowSet(sql, param);
5151
response.getWriter().println("Your results are: ");
5252

5353
while (results.next()) {

0 commit comments

Comments
 (0)