diff --git a/core-codemods/src/test/java/io/codemodder/codemods/MoveSwitchDefaultCaseLastCodemodTest.java b/core-codemods/src/test/java/io/codemodder/codemods/MoveSwitchDefaultCaseLastCodemodTest.java
index a10566269..f99aca765 100644
--- a/core-codemods/src/test/java/io/codemodder/codemods/MoveSwitchDefaultCaseLastCodemodTest.java
+++ b/core-codemods/src/test/java/io/codemodder/codemods/MoveSwitchDefaultCaseLastCodemodTest.java
@@ -57,9 +57,9 @@ void foo() {
break;
default:
break;
- case 0:
- break;
- }
+ case 0:
+ break;
+ }
}
}
""";
diff --git a/core-codemods/src/test/java/io/codemodder/codemods/SQLParameterizerCodemodTest.java b/core-codemods/src/test/java/io/codemodder/codemods/SQLParameterizerCodemodTest.java
index 9b0a69455..88a5c5406 100644
--- a/core-codemods/src/test/java/io/codemodder/codemods/SQLParameterizerCodemodTest.java
+++ b/core-codemods/src/test/java/io/codemodder/codemods/SQLParameterizerCodemodTest.java
@@ -2,9 +2,21 @@
import io.codemodder.testutils.CodemodTestMixin;
import io.codemodder.testutils.Metadata;
+import org.junit.jupiter.api.Nested;
-@Metadata(
- codemodType = SQLParameterizerCodemod.class,
- testResourceDir = "sql-parameterizer",
- dependencies = {})
-final class SQLParameterizerCodemodTest implements CodemodTestMixin {}
+final class SQLParameterizerCodemodTest {
+
+ @Nested
+ @Metadata(
+ codemodType = SQLParameterizerCodemod.class,
+ testResourceDir = "sql-parameterizer/defaultTransformation",
+ dependencies = {})
+ class DefaultTransformationTest implements CodemodTestMixin {}
+
+ @Nested
+ @Metadata(
+ codemodType = SQLParameterizerCodemod.class,
+ testResourceDir = "sql-parameterizer/hijackTransformation",
+ dependencies = {})
+ class HijackTransformationTest implements CodemodTestMixin {}
+}
diff --git a/core-codemods/src/test/resources/defectdojo-sql-injection/SqlInjectionChallenge/SqlInjectionChallenge.java.after b/core-codemods/src/test/resources/defectdojo-sql-injection/SqlInjectionChallenge/SqlInjectionChallenge.java.after
index eb7086476..f74fbc82d 100644
--- a/core-codemods/src/test/resources/defectdojo-sql-injection/SqlInjectionChallenge/SqlInjectionChallenge.java.after
+++ b/core-codemods/src/test/resources/defectdojo-sql-injection/SqlInjectionChallenge/SqlInjectionChallenge.java.after
@@ -68,6 +68,7 @@ public class SqlInjectionChallenge extends AssignmentEndpoint {
"select userid from sql_challenge_users where userid = ?";
PreparedStatement statement = connection.prepareStatement(checkUserQuery);
statement.setString(1, username_reg);
+
ResultSet resultSet = statement.execute();
if (resultSet.next()) {
if (username_reg.contains("tom'")) {
@@ -84,7 +85,6 @@ public class SqlInjectionChallenge extends AssignmentEndpoint {
preparedStatement.execute();
attackResult = success(this).feedback("user.created").feedbackArgs(username_reg).build();
}
-
} catch (SQLException e) {
attackResult = failed(this).output("Something went wrong").build();
}
diff --git a/core-codemods/src/test/resources/defectdojo-sql-injection/SqlInjectionLesson8/SqlInjectionLesson8.java.after b/core-codemods/src/test/resources/defectdojo-sql-injection/SqlInjectionLesson8/SqlInjectionLesson8.java.after
index d6c77cb58..efde86db4 100644
--- a/core-codemods/src/test/resources/defectdojo-sql-injection/SqlInjectionLesson8/SqlInjectionLesson8.java.after
+++ b/core-codemods/src/test/resources/defectdojo-sql-injection/SqlInjectionLesson8/SqlInjectionLesson8.java.after
@@ -70,9 +70,10 @@ public class SqlInjectionLesson8 extends AssignmentEndpoint {
try {
PreparedStatement statement =
connection.prepareStatement(
-query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
+ query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
log(connection, query);
statement.setString(1, name);
+
statement.setString(2, auth_tan);
ResultSet results = statement.execute();
if (results.getStatement() != null) {
@@ -98,7 +99,6 @@ query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDAT
} else {
return failed(this).build();
}
-
} catch (SQLException e) {
return failed(this)
.output("
" + e.getMessage() + "")
@@ -156,7 +156,7 @@ query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDAT
statement.setString(1, sdf.format(cal.getTime()));
statement.setString(2, action);
statement.execute();
- } catch (SQLException e) {
+ } catch (SQLException e) {
System.err.println(e.getMessage());
}
}
diff --git a/core-codemods/src/test/resources/jexl-expression-injection/Test.java.after b/core-codemods/src/test/resources/jexl-expression-injection/Test.java.after
index f4d80f6bb..9f0543d61 100644
--- a/core-codemods/src/test/resources/jexl-expression-injection/Test.java.after
+++ b/core-codemods/src/test/resources/jexl-expression-injection/Test.java.after
@@ -27,7 +27,6 @@ public final class Test {
JexlExpression expression = jexl.createExpression(input);
JexlContext context = new MapContext();
expression.evaluate(context);
-
}
}
@@ -42,7 +41,6 @@ public final class Test {
sandbox.block(cls);
}
new JexlBuilder().sandbox(sandbox).create().createExpression(input).evaluate(context);
-
}
}
diff --git a/core-codemods/src/test/resources/move-switch-default-last/Test.java.after b/core-codemods/src/test/resources/move-switch-default-last/Test.java.after
index 6dd475c2d..75c89e56f 100644
--- a/core-codemods/src/test/resources/move-switch-default-last/Test.java.after
+++ b/core-codemods/src/test/resources/move-switch-default-last/Test.java.after
@@ -11,8 +11,8 @@ final class Test {
case "bar":
System.out.println("bar");
break;
-default:
- System.out.println("default"); }
+ default:
+ System.out.println("default");}
System.out.println("bar");
}
diff --git a/core-codemods/src/test/resources/semgrep-sql-injection-formatted-sql-string/SqlInjectionLesson5a.java.after b/core-codemods/src/test/resources/semgrep-sql-injection-formatted-sql-string/SqlInjectionLesson5a.java.after
index a83b4902a..781e920e4 100644
--- a/core-codemods/src/test/resources/semgrep-sql-injection-formatted-sql-string/SqlInjectionLesson5a.java.after
+++ b/core-codemods/src/test/resources/semgrep-sql-injection-formatted-sql-string/SqlInjectionLesson5a.java.after
@@ -64,8 +64,9 @@ public class SqlInjectionLesson5a extends AssignmentEndpoint {
"SELECT * FROM user_data WHERE first_name = 'John' and last_name = ?";
try (PreparedStatement statement =
connection.prepareStatement(
-query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE)) {
+ query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE)) {
statement.setString(1, accountName);
+
ResultSet results = statement.execute();
if ((results != null) && (results.first())) {
ResultSetMetaData resultsMetaData = results.getMetaData();
@@ -90,7 +91,6 @@ query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATAB
.output("Your query was: " + query)
.build();
}
-
} catch (SQLException sqle) {
return failed(this).output(sqle.getMessage() + "
Your query was: " + query).build();
}
@@ -135,4 +135,4 @@ query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATAB
t.append("
(0) If the execute call is the following resource, break the try into two statements; * - *
(1.a) Create a new PreparedStatement pstmt object; + *
(1) Add a setString for every injection parameter; * - *
(1.b) Change Statement type to PreparedStatement and createStatement to prepareStatement; + *
(2.a) Create a new PreparedStatement pstmt object; * - *
(2) Add a setString for every injection parameter; + *
(2.b) Change Statement type to PreparedStatement and createStatement to prepareStatement; * *
(3) Change