CVE-2018-1290-1291-1292
This commit is contained in:
+4
@@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.fineract.infrastructure.core.api;
|
package org.apache.fineract.infrastructure.core.api;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -30,6 +31,7 @@ import javax.ws.rs.core.MultivaluedMap;
|
|||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.fineract.infrastructure.core.serialization.JsonParserHelper;
|
import org.apache.fineract.infrastructure.core.serialization.JsonParserHelper;
|
||||||
|
import org.apache.fineract.infrastructure.security.utils.SQLInjectionValidator;
|
||||||
|
|
||||||
public class ApiParameterHelper {
|
public class ApiParameterHelper {
|
||||||
|
|
||||||
@@ -166,8 +168,10 @@ public class ApiParameterHelper {
|
|||||||
public static String sqlEncodeString(final String str) {
|
public static String sqlEncodeString(final String str) {
|
||||||
final String singleQuote = "'";
|
final String singleQuote = "'";
|
||||||
final String twoSingleQuotes = "''";
|
final String twoSingleQuotes = "''";
|
||||||
|
SQLInjectionValidator.validateSQLInput(str);
|
||||||
return singleQuote + StringUtils.replace(str, singleQuote, twoSingleQuotes, -1) + singleQuote;
|
return singleQuote + StringUtils.replace(str, singleQuote, twoSingleQuotes, -1) + singleQuote;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Map<String, String> asMap(final MultivaluedMap<String, String> queryParameters) {
|
public static Map<String, String> asMap(final MultivaluedMap<String, String> queryParameters) {
|
||||||
|
|
||||||
|
|||||||
+7
-2
@@ -49,6 +49,7 @@ import org.apache.fineract.infrastructure.dataqueries.exception.ReportNotFoundEx
|
|||||||
import org.apache.fineract.infrastructure.documentmanagement.contentrepository.FileSystemContentRepository;
|
import org.apache.fineract.infrastructure.documentmanagement.contentrepository.FileSystemContentRepository;
|
||||||
import org.apache.fineract.infrastructure.report.provider.ReportingProcessServiceProvider;
|
import org.apache.fineract.infrastructure.report.provider.ReportingProcessServiceProvider;
|
||||||
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
|
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
|
||||||
|
import org.apache.fineract.infrastructure.security.utils.ColumnValidator;
|
||||||
import org.apache.fineract.useradministration.domain.AppUser;
|
import org.apache.fineract.useradministration.domain.AppUser;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -73,16 +74,19 @@ public class ReadReportingServiceImpl implements ReadReportingService {
|
|||||||
private final PlatformSecurityContext context;
|
private final PlatformSecurityContext context;
|
||||||
private final GenericDataService genericDataService;
|
private final GenericDataService genericDataService;
|
||||||
private final ReportingProcessServiceProvider reportingProcessServiceProvider;
|
private final ReportingProcessServiceProvider reportingProcessServiceProvider;
|
||||||
|
private final ColumnValidator columnValidator;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public ReadReportingServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource,
|
public ReadReportingServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource,
|
||||||
final GenericDataService genericDataService, final ReportingProcessServiceProvider reportingProcessServiceProvider) {
|
final GenericDataService genericDataService, final ReportingProcessServiceProvider reportingProcessServiceProvider,
|
||||||
|
final ColumnValidator columnValidator) {
|
||||||
|
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.dataSource = dataSource;
|
this.dataSource = dataSource;
|
||||||
this.jdbcTemplate = new JdbcTemplate(this.dataSource);
|
this.jdbcTemplate = new JdbcTemplate(this.dataSource);
|
||||||
this.genericDataService = genericDataService;
|
this.genericDataService = genericDataService;
|
||||||
this.reportingProcessServiceProvider = reportingProcessServiceProvider;
|
this.reportingProcessServiceProvider = reportingProcessServiceProvider;
|
||||||
|
this.columnValidator = columnValidator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -221,7 +225,8 @@ public class ReadReportingServiceImpl implements ReadReportingService {
|
|||||||
public String getReportType(final String reportName) {
|
public String getReportType(final String reportName) {
|
||||||
|
|
||||||
final String sql = "SELECT ifnull(report_type,'') as report_type FROM `stretchy_report` where report_name = '" + reportName + "'";
|
final String sql = "SELECT ifnull(report_type,'') as report_type FROM `stretchy_report` where report_name = '" + reportName + "'";
|
||||||
|
this.columnValidator.validateSqlInjection(sql, reportName);
|
||||||
|
|
||||||
final String sqlWrapped = this.genericDataService.wrapSQL(sql);
|
final String sqlWrapped = this.genericDataService.wrapSQL(sql);
|
||||||
|
|
||||||
final SqlRowSet rs = this.jdbcTemplate.queryForRowSet(sqlWrapped);
|
final SqlRowSet rs = this.jdbcTemplate.queryForRowSet(sqlWrapped);
|
||||||
|
|||||||
+6
-1
@@ -49,6 +49,7 @@ import org.apache.fineract.infrastructure.dataqueries.exception.DatatableEntryRe
|
|||||||
import org.apache.fineract.infrastructure.dataqueries.exception.DatatableNotFoundException;
|
import org.apache.fineract.infrastructure.dataqueries.exception.DatatableNotFoundException;
|
||||||
import org.apache.fineract.infrastructure.dataqueries.exception.DatatableSystemErrorException;
|
import org.apache.fineract.infrastructure.dataqueries.exception.DatatableSystemErrorException;
|
||||||
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
|
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
|
||||||
|
import org.apache.fineract.infrastructure.security.utils.ColumnValidator;
|
||||||
import org.apache.fineract.infrastructure.security.utils.SQLInjectionValidator;
|
import org.apache.fineract.infrastructure.security.utils.SQLInjectionValidator;
|
||||||
import org.apache.fineract.useradministration.domain.AppUser;
|
import org.apache.fineract.useradministration.domain.AppUser;
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
@@ -106,6 +107,7 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
|
|||||||
private final ConfigurationDomainService configurationDomainService;
|
private final ConfigurationDomainService configurationDomainService;
|
||||||
private final CodeReadPlatformService codeReadPlatformService;
|
private final CodeReadPlatformService codeReadPlatformService;
|
||||||
private final DataTableValidator dataTableValidator;
|
private final DataTableValidator dataTableValidator;
|
||||||
|
private final ColumnValidator columnValidator;
|
||||||
|
|
||||||
// private final GlobalConfigurationWritePlatformServiceJpaRepositoryImpl
|
// private final GlobalConfigurationWritePlatformServiceJpaRepositoryImpl
|
||||||
// configurationWriteService;
|
// configurationWriteService;
|
||||||
@@ -114,7 +116,8 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
|
|||||||
public ReadWriteNonCoreDataServiceImpl(final RoutingDataSource dataSource, final PlatformSecurityContext context,
|
public ReadWriteNonCoreDataServiceImpl(final RoutingDataSource dataSource, final PlatformSecurityContext context,
|
||||||
final FromJsonHelper fromJsonHelper, final GenericDataService genericDataService,
|
final FromJsonHelper fromJsonHelper, final GenericDataService genericDataService,
|
||||||
final DatatableCommandFromApiJsonDeserializer fromApiJsonDeserializer, final CodeReadPlatformService codeReadPlatformService,
|
final DatatableCommandFromApiJsonDeserializer fromApiJsonDeserializer, final CodeReadPlatformService codeReadPlatformService,
|
||||||
final ConfigurationDomainService configurationDomainService, final DataTableValidator dataTableValidator) {
|
final ConfigurationDomainService configurationDomainService, final DataTableValidator dataTableValidator,
|
||||||
|
final ColumnValidator columnValidator) {
|
||||||
this.dataSource = dataSource;
|
this.dataSource = dataSource;
|
||||||
this.jdbcTemplate = new JdbcTemplate(this.dataSource);
|
this.jdbcTemplate = new JdbcTemplate(this.dataSource);
|
||||||
this.context = context;
|
this.context = context;
|
||||||
@@ -125,6 +128,7 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
|
|||||||
this.codeReadPlatformService = codeReadPlatformService;
|
this.codeReadPlatformService = codeReadPlatformService;
|
||||||
this.configurationDomainService = configurationDomainService;
|
this.configurationDomainService = configurationDomainService;
|
||||||
this.dataTableValidator = dataTableValidator;
|
this.dataTableValidator = dataTableValidator;
|
||||||
|
this.columnValidator = columnValidator;
|
||||||
// this.configurationWriteService = configurationWriteService;
|
// this.configurationWriteService = configurationWriteService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1183,6 +1187,7 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
|
|||||||
sql = sql + "select * from `" + dataTableName + "` where id = " + id;
|
sql = sql + "select * from `" + dataTableName + "` where id = " + id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.columnValidator.validateSqlInjection(sql, order);
|
||||||
if (order != null) {
|
if (order != null) {
|
||||||
sql = sql + " order by " + order;
|
sql = sql + " order by " + order;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user