mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fix(dynamodb): reject out-of-bound query cursors (#3389)
Signed-off-by: 7487 <1042653432@qq.com>
This commit is contained in:
1 parent
ce073930b9
commit
862e4a1c77
2 files changed
+64
No files matched your search
@@ -944,6 +944,8 @@ public class DynamoDbService implements ResourceProvider {
|
||||
String partitionKeyValuePlaceholder = DynamoDbAccessPathValidator.validateQuery(
|
||||
table, accessPath, keyConditions, keyConditionExpression, filterExpression,
|
||||
null, exprAttrNames, expressionAttrValues);
|
||||
validateExclusiveStartKeyWithinQuery(exclusiveStartKey, table, accessPath, keyConditions,
|
||||
keyConditionExpression, expressionAttrValues, exprAttrNames);
|
||||
String pkName = accessPath.partitionKeyName();
|
||||
List<String> pkNames = accessPath.partitionKeyNames();
|
||||
String skName = accessPath.sortKeyName();
|
||||
@@ -3371,6 +3373,26 @@ public class DynamoDbService implements ResourceProvider {
|
||||
};
|
||||
}
|
||||
|
||||
private void validateExclusiveStartKeyWithinQuery(JsonNode exclusiveStartKey, TableDefinition table,
|
||||
DynamoDbAccessPath accessPath, JsonNode keyConditions,
|
||||
String keyConditionExpression, JsonNode expressionAttrValues,
|
||||
JsonNode expressionAttrNames) {
|
||||
if (exclusiveStartKey == null || exclusiveStartKey.isNull()) {
|
||||
return;
|
||||
}
|
||||
DynamoDbAccessPathValidator.validateExclusiveStartKey(exclusiveStartKey, table, accessPath, false);
|
||||
|
||||
boolean withinBounds = keyConditionExpression != null
|
||||
? ExpressionEvaluator.matches(keyConditionExpression, exclusiveStartKey,
|
||||
expressionAttrNames, expressionAttrValues)
|
||||
: keyConditions.properties().stream().allMatch(entry ->
|
||||
matchesKeyCondition(exclusiveStartKey.get(entry.getKey()), entry.getValue()));
|
||||
if (!withinBounds) {
|
||||
throw new AwsException("ValidationException",
|
||||
"The provided starting key is outside query boundaries based on provided condition", 400);
|
||||
}
|
||||
}
|
||||
|
||||
private List<JsonNode> queryWithExpression(ConcurrentSkipListMap<String, JsonNode> items,
|
||||
String partitionKeyName,
|
||||
String partitionKeyValuePlaceholder,
|
||||
|
||||
Reference in new issue
Block a user