Skip to content

Commit 47fa081

Browse files
authored
feat: remove limits on list length and map size (#819)
1 parent ae68fb7 commit 47fa081

File tree

2 files changed

+0
-12
lines changed

2 files changed

+0
-12
lines changed

Diff for: DynamoDbEncryption/dafny/DynamoDbEncryption/src/DynamoToStruct.dfy

-8
Original file line numberDiff line numberDiff line change
@@ -541,9 +541,7 @@ module DynamoToStruct {
541541
// See "The Parent Trick" for details: <https://leino.science/papers/krml283.html>.
542542
function method MapAttrToBytes(ghost parent: AttributeValue, m: MapAttributeValue, depth : nat): (ret: Result<seq<uint8>, string>)
543543
requires forall kv <- m.Items :: kv.1 < parent
544-
ensures MAX_MAP_SIZE < |m| ==> ret.Failure?
545544
{
546-
:- Need(|m| <= MAX_MAP_SIZE, "Map exceeds limit of " + MAX_MAP_SIZE_STR + " entries.");
547545
//= specification/dynamodb-encryption-client/ddb-attribute-serialization.md#value-type
548546
//# Value Type MUST be the [Type ID](#type-id) of the type of [Map Value](#map-value).
549547

@@ -565,9 +563,7 @@ module DynamoToStruct {
565563
}
566564

567565
function method ListAttrToBytes(l: ListAttributeValue, depth : nat): (ret: Result<seq<uint8>, string>)
568-
ensures MAX_LIST_LENGTH < |l| ==> ret.Failure?
569566
{
570-
:- Need(|l| <= MAX_LIST_LENGTH, "List exceeds limit of " + MAX_LIST_LENGTH_STR + " entries.");
571567
var count :- U32ToBigEndian(|l|);
572568
var body :- CollectList(l, depth);
573569
Success(count + body)
@@ -917,7 +913,6 @@ module DynamoToStruct {
917913
resultList : AttrValueAndLength)
918914
: (ret : Result<AttrValueAndLength, string>)
919915
requires resultList.val.L?
920-
requires remainingCount <= MAX_LIST_LENGTH
921916
ensures ret.Success? ==> ret.value.val.L?
922917
requires |serialized| + resultList.len == origSerializedSize
923918
ensures ret.Success? ==> ret.value.len <= origSerializedSize
@@ -950,7 +945,6 @@ module DynamoToStruct {
950945
resultMap : AttrValueAndLength)
951946
: (ret : Result<AttrValueAndLength, string>)
952947
requires resultMap.val.M?
953-
requires remainingCount <= MAX_MAP_SIZE
954948
ensures ret.Success? ==> ret.value.val.M?
955949
requires |serialized| + resultMap.len == origSerializedSize
956950
ensures ret.Success? ==> ret.value.len <= origSerializedSize
@@ -1085,7 +1079,6 @@ module DynamoToStruct {
10851079
Failure("List Structured Data has less than 4 bytes")
10861080
else
10871081
var len :- BigEndianToU32(value);
1088-
:- Need(len <= MAX_MAP_SIZE, "Map exceeds limit of " + MAX_MAP_SIZE_STR + " entries.");
10891082
var value := value[LENGTH_LEN..];
10901083
DeserializeMap(value, len, |value| + LENGTH_LEN + lengthBytes, depth, AttrValueAndLength(AttributeValue.M(map[]), LENGTH_LEN + lengthBytes))
10911084

@@ -1094,7 +1087,6 @@ module DynamoToStruct {
10941087
Failure("List Structured Data has less than 4 bytes")
10951088
else
10961089
var len :- BigEndianToU32(value);
1097-
:- Need(len <= MAX_LIST_LENGTH, "List exceeds limit of " + MAX_LIST_LENGTH_STR + " entries.");
10981090
var value := value[LENGTH_LEN..];
10991091
DeserializeList(value, len, |value| + LENGTH_LEN + lengthBytes, depth, AttrValueAndLength(AttributeValue.L([]), LENGTH_LEN + lengthBytes))
11001092

Diff for: DynamoDbEncryption/dafny/DynamoDbEncryption/src/Util.dfy

-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ module DynamoDbEncryptionUtil {
1616

1717
const MAX_STRUCTURE_DEPTH := 32
1818
const MAX_STRUCTURE_DEPTH_STR := "32"
19-
const MAX_LIST_LENGTH := 100
20-
const MAX_LIST_LENGTH_STR := "100"
21-
const MAX_MAP_SIZE := 100
22-
const MAX_MAP_SIZE_STR := "100"
2319

2420
type HmacKeyMap = map<string, Bytes>
2521

0 commit comments

Comments
 (0)