need to verify input before doing anything and disregard what codacy says about this

This commit is contained in:
Brian Sweeney 2018-08-28 08:49:02 -06:00
parent e24aed2e56
commit d85c20c85a

View File

@ -1817,6 +1817,9 @@ abstract class AbstractSqlEamDb implements EamDb {
@Override
public boolean isArtifactKnownBadByReference(CorrelationAttributeInstance.Type aType, String value) throws EamDbException, CorrelationAttributeNormalizationException {
//this should be done here so that we can be certain that aType and value are valid before we proceed
String normalizeValued = CorrelationAttributeNormalizer.normalize(aType, value);
// TEMP: Only support file correlation type
if (aType.getId() != CorrelationAttributeInstance.FILES_TYPE_ID) {
return false;
@ -1830,8 +1833,6 @@ abstract class AbstractSqlEamDb implements EamDb {
String sql = "SELECT count(*) FROM %s WHERE value=? AND known_status=?";
try {
String normalizeValued = CorrelationAttributeNormalizer.normalize(aType, value);
preparedStatement = conn.prepareStatement(String.format(sql, EamDbUtil.correlationTypeToReferenceTableName(aType)));
preparedStatement.setString(1, normalizeValued);
preparedStatement.setByte(2, TskData.FileKnown.BAD.getFileKnownValue());