[chore](vulnerability) fix fe high risk vulnerability scanned by bug scanner (#15649)

This commit is contained in:
Zhengguo Yang
2023-01-10 17:44:18 +08:00
committed by GitHub
parent 672d11522b
commit 503b6ee4da
19 changed files with 86 additions and 28 deletions

View File

@ -320,20 +320,24 @@ public class BitmapValue {
}
}
public boolean equals(BitmapValue other) {
boolean ret = false;
if (this.bitmapType != other.bitmapType) {
@Override
public boolean equals(Object other) {
if (other == null || !(other instanceof BitmapValue)) {
return false;
}
switch (other.bitmapType) { // CHECKSTYLE IGNORE THIS LINE: missing switch default
boolean ret = false;
if (this.bitmapType != ((BitmapValue) other).bitmapType) {
return false;
}
switch (((BitmapValue) other).bitmapType) { // CHECKSTYLE IGNORE THIS LINE: missing switch default
case EMPTY:
ret = true;
break;
case SINGLE_VALUE:
ret = this.singleValue == other.singleValue;
ret = this.singleValue == ((BitmapValue) other).singleValue;
break;
case BITMAP_VALUE:
ret = bitmap.equals(other.bitmap);
ret = bitmap.equals(((BitmapValue) other).bitmap);
}
return ret;
}

View File

@ -281,7 +281,7 @@ public final class FieldReflection {
private static boolean isSameType(Class<?> firstType, Class<?> secondType) {
return firstType == secondType
|| firstType.isPrimitive() && firstType == AutoType.getPrimitiveType(secondType)
|| secondType.isPrimitive() && firstType == AutoType.getPrimitiveType(secondType);
|| secondType.isPrimitive() && secondType == AutoType.getPrimitiveType(firstType);
}
}

View File

@ -158,6 +158,6 @@ public final class MethodReflection {
private static boolean isSameType(Class<?> firstType, Class<?> secondType) {
return firstType == secondType
|| firstType.isPrimitive() && firstType == AutoType.getPrimitiveType(secondType)
|| secondType.isPrimitive() && firstType == AutoType.getPrimitiveType(secondType);
|| secondType.isPrimitive() && secondType == AutoType.getPrimitiveType(firstType);
}
}

View File

@ -357,9 +357,8 @@ public class BinaryPredicate extends Predicate implements Writable {
if (t1 == PrimitiveType.VARCHAR && t2 == PrimitiveType.VARCHAR) {
return Type.VARCHAR;
}
if (t1 == PrimitiveType.STRING && t2 == PrimitiveType.STRING
|| t1 == PrimitiveType.STRING && t2 == PrimitiveType.VARCHAR
|| t1 == PrimitiveType.VARCHAR && t2 == PrimitiveType.STRING) {
if ((t1 == PrimitiveType.STRING && (t2 == PrimitiveType.VARCHAR || t2 == PrimitiveType.STRING)) || (
t2 == PrimitiveType.STRING && (t1 == PrimitiveType.VARCHAR || t1 == PrimitiveType.STRING))) {
return Type.STRING;
}
if (t1 == PrimitiveType.BIGINT && t2 == PrimitiveType.BIGINT) {

View File

@ -66,6 +66,9 @@ public class ColumnPartitionDesc extends PartitionDesc {
}
}
}
if (matched == null) {
throw new AnalysisException("The partition columns doesn't match the ones in base table.");
}
PartitionInfo partitionInfo = matched.getPartitionInfo();
List<Column> partitionColumns = partitionInfo.getPartitionColumns();
if (!columns.stream().map(SlotRef::getColumn).collect(Collectors.toList()).equals(partitionColumns)) {

View File

@ -571,9 +571,7 @@ public class CreateTableStmt extends DdlStmt {
}
}
sb.append("\n)");
if (engineName != null) {
sb.append(" ENGINE = ").append(engineName);
}
sb.append(" ENGINE = ").append(engineName);
if (keysDesc != null) {
sb.append("\n").append(keysDesc.toSql());

View File

@ -782,7 +782,7 @@ public abstract class Type {
|| scalarType.getType() == TPrimitiveType.DECIMAL64
|| scalarType.getType() == TPrimitiveType.DECIMAL128I) {
Preconditions.checkState(scalarType.isSetPrecision()
&& scalarType.isSetPrecision());
&& scalarType.isSetScale());
type = ScalarType.createDecimalV3Type(scalarType.getPrecision(),
scalarType.getScale());
} else if (scalarType.getType() == TPrimitiveType.DATETIMEV2) {

View File

@ -347,6 +347,8 @@ public class DynamicPartitionScheduler extends MasterDaemon {
reservedHistoryPartitionKeyRangeList.add(reservedHistoryPartitionKeyRange);
} catch (IllegalArgumentException e) {
return dropPartitionClauses;
} catch (AnalysisException e) {
throw new DdlException(e.getMessage());
}
}
}
@ -390,7 +392,7 @@ public class DynamicPartitionScheduler extends MasterDaemon {
}
ArrayList<AddPartitionClause> addPartitionClauses = new ArrayList<>();
ArrayList<DropPartitionClause> dropPartitionClauses = null;
ArrayList<DropPartitionClause> dropPartitionClauses = new ArrayList<>();
String tableName = null;
boolean skipAddPartition = false;
OlapTable olapTable;

View File

@ -729,7 +729,7 @@ public class DynamicPartitionUtil {
}
public static String getHistoryPartitionRangeString(DynamicPartitionProperty dynamicPartitionProperty,
String time, String format) {
String time, String format) throws AnalysisException {
ZoneId zoneId = dynamicPartitionProperty.getTimeZone().toZoneId();
Date date = null;
Timestamp timestamp = null;
@ -740,8 +740,7 @@ public class DynamicPartitionUtil {
date = simpleDateFormat.parse(time);
} catch (ParseException e) {
LOG.warn("Parse dynamic partition periods error. Error={}", e.getMessage());
return getFormattedTimeWithoutMinuteSecond(
ZonedDateTime.parse(timestamp.toString(), dateTimeFormatter), format);
throw new AnalysisException("Parse dynamic partition periods error. Error=" + e.getMessage());
}
timestamp = new Timestamp(date.getTime());
return getFormattedTimeWithoutMinuteSecond(

View File

@ -133,7 +133,7 @@ public class LocalFileDeployManager extends DeployManager {
LOG.warn("failed to close buffered reader after reading file: {}", clusterInfoFile, e);
}
}
if (lock != null && channel.isOpen()) {
if (lock != null) {
try {
lock.release();
} catch (IOException e) {

View File

@ -152,7 +152,7 @@ public class IcebergTableCreationRecordMgr extends MasterDaemon {
try {
icebergTables = icebergCatalog.listTables(icebergProperty.getDatabase());
} catch (DorisIcebergException e) {
} catch (Exception e) {
addTableCreationRecord(db.getId(), -1, db.getFullName(), "", FAIL,
prop.writeTimeFormat(new Date(System.currentTimeMillis())), e.getMessage());
LOG.warn("Failed list remote Iceberg database, hive.metastore.uris[{}], database[{}], error: {}",

View File

@ -88,7 +88,7 @@ public class GetLogFileAction extends RestBaseController {
return ResponseEntityBuilder.internalError(e.getMessage());
}
} else {
return ResponseEntityBuilder.okWithCommonError("Log file not exist: " + log.getName());
return ResponseEntityBuilder.okWithCommonError("Log file not exist: " + logFile);
}
}
return ResponseEntityBuilder.ok();

View File

@ -408,6 +408,49 @@ public class DppConfig implements Writable {
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (!(obj instanceof DppConfig)) {
return false;
}
DppConfig other = (DppConfig) obj;
if (paloPath == null) {
if (other.paloPath != null) {
return false;
}
} else {
if (!paloPath.equals(other.paloPath)) {
return false;
}
}
if (httpPort != other.httpPort) {
return false;
}
if (hadoopConfigs == null) {
if (other.hadoopConfigs != null) {
return false;
}
} else {
if (!hadoopConfigs.equals(other.hadoopConfigs)) {
return false;
}
}
if (priority == null) {
if (other.priority != null) {
return false;
}
} else {
if (!priority.equals(other.priority)) {
return false;
}
}
return true;
}
}

View File

@ -54,6 +54,16 @@ public class EtlJobInfo implements Writable {
@Override
public boolean equals(Object obj) {
return true;
if (obj == null) {
return false;
}
if (this == obj) {
return true;
}
if (obj instanceof EtlJobInfo) {
EtlJobInfo other = (EtlJobInfo) obj;
return jobStatus.equals(other.jobStatus);
}
return false;
}
}

View File

@ -97,7 +97,7 @@ public class TableAddOrDropColumnsInfo implements Writable {
TableAddOrDropColumnsInfo info = (TableAddOrDropColumnsInfo) obj;
return (dbId == info.dbId && tableId == tableId
return (dbId == info.dbId && tableId == info.tableId
&& indexSchemaMap.equals(info.indexSchemaMap) && indexes.equals(info.indexes)
&& jobId == info.jobId);
}

View File

@ -85,7 +85,7 @@ public class TableRenameColumnInfo implements Writable {
TableRenameColumnInfo info = (TableRenameColumnInfo) obj;
return (dbId == info.dbId && tableId == tableId
return (dbId == info.dbId && tableId == info.tableId
&& colName.equals(info.colName) && newColName.equals(info.newColName));
}

View File

@ -1712,7 +1712,7 @@ public class SingleNodePlanner {
return;
}
preds.removeAll(pushDownFailedPredicates);
unassignedConjuncts.remove(preds);
unassignedConjuncts.removeAll(preds);
unassignedConjuncts.addAll(pushDownFailedPredicates);
// Remove unregistered predicates that reference the same slot on

View File

@ -163,7 +163,7 @@ public class CatalogTestUtil {
if (slaveReplica.getBackendId() != masterReplica.getBackendId()
|| slaveReplica.getVersion() != masterReplica.getVersion()
|| slaveReplica.getLastFailedVersion() != masterReplica.getLastFailedVersion()
|| slaveReplica.getLastSuccessVersion() != slaveReplica.getLastSuccessVersion()) {
|| slaveReplica.getLastSuccessVersion() != masterReplica.getLastSuccessVersion()) {
return false;
}
}

View File

@ -459,7 +459,7 @@ public class TableFunctionPlanTest {
String sql = "desc verbose select min(c1) from (select k1 as c1, min(k2) as c2 from db1.tbl1 group by c1) a "
+ "lateral view explode_split(c2, \",\") tmp1 as e1 order by min(c1)";
String errorMsg = UtFrameUtils.getSQLPlanOrErrorMsg(ctx, sql, true);
errorMsg.equalsIgnoreCase("lateral view as a inline view");
Assert.assertTrue(errorMsg.toLowerCase().contains("lateral view as a inline view"));
}
/*