forked from github/dataease
fix: 修复SQL注入漏洞
This commit is contained in:
parent
49555ab90f
commit
65dd5eb9f8
@ -14,6 +14,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -28,7 +29,9 @@ public class H2EngineProvider extends EngineProvider {
|
|||||||
CoreDatasource datasource = new CoreDatasource();
|
CoreDatasource datasource = new CoreDatasource();
|
||||||
BeanUtils.copyBean(datasource, engineRequest.getEngine());
|
BeanUtils.copyBean(datasource, engineRequest.getEngine());
|
||||||
try (Connection connection = getConnection(datasource); Statement stat = getStatement(connection, queryTimeout)) {
|
try (Connection connection = getConnection(datasource); Statement stat = getStatement(connection, queryTimeout)) {
|
||||||
Boolean result = stat.execute(engineRequest.getQuery());
|
PreparedStatement preparedStatement = connection.prepareStatement(engineRequest.getQuery());
|
||||||
|
preparedStatement.setQueryTimeout(queryTimeout);
|
||||||
|
Boolean result = preparedStatement.execute();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -32,7 +33,9 @@ public class MysqlEngineProvider extends EngineProvider {
|
|||||||
CoreDatasource datasource = new CoreDatasource();
|
CoreDatasource datasource = new CoreDatasource();
|
||||||
BeanUtils.copyBean(datasource, engineRequest.getEngine());
|
BeanUtils.copyBean(datasource, engineRequest.getEngine());
|
||||||
try (Connection connection = getConnection(datasource); Statement stat = getStatement(connection, queryTimeout)) {
|
try (Connection connection = getConnection(datasource); Statement stat = getStatement(connection, queryTimeout)) {
|
||||||
Boolean result = stat.execute(engineRequest.getQuery());
|
PreparedStatement preparedStatement = connection.prepareStatement(engineRequest.getQuery());
|
||||||
|
preparedStatement.setQueryTimeout(queryTimeout);
|
||||||
|
Boolean result = preparedStatement.execute();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user