Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.apache.commons.lang3.time.FastDateFormat;
import org.h2.jdbc.JdbcBlob;
import org.h2.jdbc.JdbcClob;
import org.jumpmind.db.sql.SqlUtils;
import org.jumpmind.symmetric.db.h2.H2Trigger;
import org.jumpmind.symmetric.db.hsqldb.HsqlDbTrigger;

Expand Down Expand Up @@ -286,8 +287,9 @@
protected Map<String, String> getTemplates(Connection conn) throws SQLException {
Map<String, String> templates = new HashMap<String, String>();
try (Statement stmt = conn.createStatement()) {
String schemaPrefix = schemaName != null && schemaName.length() > 0 ? "\"" + schemaName + "\"." : "";
ResultSet rs = stmt.executeQuery(String.format("select * from %s%s%s", schemaPrefix, triggerName, TEMPLATE_TABLE_SUFFIX));
String schemaPrefix = schemaName != null && schemaName.length() > 0 ? "\"" + SqlUtils.sanitizeIdentifier(schemaName) + "\"." : "";

Check warning on line 290 in symmetric-client/src/main/java/org/jumpmind/symmetric/db/AbstractEmbeddedTrigger.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use "isEmpty()" to check whether a "String" is empty or not.

See more on https://sonarcloud.io/project/issues?id=jumpmindinc_symmetric-ds&issues=AaAWtOaDdxjKDOyczlZv&open=AaAWtOaDdxjKDOyczlZv&pullRequest=1004
ResultSet rs = stmt.executeQuery(String.format("select * from %s%s%s", schemaPrefix, SqlUtils.sanitizeIdentifier(triggerName),
TEMPLATE_TABLE_SUFFIX));

Check warning on line 292 in symmetric-client/src/main/java/org/jumpmind/symmetric/db/AbstractEmbeddedTrigger.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make sure using a dynamically formatted SQL query is safe here.

See more on https://sonarcloud.io/project/issues?id=jumpmindinc_symmetric-ds&issues=AaAWtOaDdxjKDOyczlZw&open=AaAWtOaDdxjKDOyczlZw&pullRequest=1004
if (rs.next()) {
ResultSetMetaData metaData = rs.getMetaData();
int columnCount = metaData.getColumnCount();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.jumpmind.db.sql.JdbcSqlTemplate;
import org.jumpmind.db.sql.JdbcSqlTransaction;
import org.jumpmind.db.sql.SqlException;
import org.jumpmind.db.sql.SqlUtils;
import org.jumpmind.db.util.BinaryEncoding;
import org.jumpmind.symmetric.SymmetricException;
import org.jumpmind.symmetric.common.ParameterConstants;
Expand Down Expand Up @@ -197,8 +198,8 @@ public void dropRequiredDatabaseObjects() {
@Override
public void removeTrigger(StringBuilder sqlBuffer, final String catalogName, String schemaName,
final String triggerName, String tableName, ISqlTransaction transaction) {
schemaName = schemaName == null ? "" : (schemaName + ".");
final String sql = "drop trigger " + schemaName + triggerName;
schemaName = schemaName == null ? "" : (SqlUtils.sanitizeIdentifier(schemaName) + ".");
final String sql = "drop trigger " + schemaName + SqlUtils.sanitizeIdentifier(triggerName);
logSql(sql, sqlBuffer);
if (parameterService.is(ParameterConstants.AUTO_SYNC_TRIGGERS) && sqlBuffer == null) {
if (log.isInfoEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.jumpmind.db.platform.DatabaseInfo;
import org.jumpmind.db.platform.postgresql.PostgreSqlJdbcSqlTemplate;
import org.jumpmind.db.sql.SqlTemplateSettings;
import org.jumpmind.db.sql.SqlUtils;
import org.jumpmind.db.sql.SymmetricLobHandler;

public class GreenplumJdbcSqlTemplate extends PostgreSqlJdbcSqlTemplate {
Expand All @@ -54,7 +55,7 @@
ResultSet rs = null;
try {
st = conn.createStatement();
rs = st.executeQuery("select nextval('" + sequenceName + "_seq')");
Comment thread
w3bbd3v-jm marked this conversation as resolved.
rs = st.executeQuery("select nextval('" + SqlUtils.sanitizeFunction(sequenceName) + "_seq')");

Check warning on line 58 in symmetric-jdbc/src/main/java/org/jumpmind/db/platform/greenplum/GreenplumJdbcSqlTemplate.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make sure using a dynamically formatted SQL query is safe here.

See more on https://sonarcloud.io/project/issues?id=jumpmindinc_symmetric-ds&issues=AaAWtOhmdxjKDOyczlZx&open=AaAWtOhmdxjKDOyczlZx&pullRequest=1004
if (rs.next()) {
key = rs.getLong(1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@
if (supportsGetGeneratedKeys) {
ps = conn.prepareStatement(sql, new int[] { 1 });
} else if (supportsReturningKeys) {
ps = conn.prepareStatement(sql + " returning " + column);
ps = conn.prepareStatement(sql + " returning " + SqlUtils.sanitizeIdentifier(column));

Check warning on line 875 in symmetric-jdbc/src/main/java/org/jumpmind/db/sql/JdbcSqlTemplate.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make sure using a dynamically formatted SQL query is safe here.

See more on https://sonarcloud.io/project/issues?id=jumpmindinc_symmetric-ds&issues=AaAWtOikdxjKDOyczlZy&open=AaAWtOikdxjKDOyczlZy&pullRequest=1004
} else {
ps = conn.prepareStatement(sql);
}
Expand Down Expand Up @@ -912,7 +912,7 @@
ps.execute();
try {
st = conn.createStatement();
rs = st.executeQuery(getSelectLastInsertIdSql(sequenceName));
rs = st.executeQuery(getSelectLastInsertIdSql(SqlUtils.sanitizeIdentifier(sequenceName)));
if (rs.next()) {
key = rs.getLong(1);
}
Expand Down
Loading