Set some length limits on various queries lengths.

This commit is contained in:
Itamar Turner-Trauring 2022-06-29 14:04:42 -04:00
parent 0e8f2aa702
commit ab80c0f0a1

View File

@ -246,12 +246,14 @@ class _HTTPError(Exception):
# https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml. Notably, #6.258 # https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml. Notably, #6.258
# indicates a set. # indicates a set.
# #
# TODO 3872 length limits in the schema. # Somewhat arbitrary limits are set to reduce e.g. number of shares, number of
# vectors, etc.. These may need to be iterated on in future revisions of the
# code.
_SCHEMAS = { _SCHEMAS = {
"allocate_buckets": Schema( "allocate_buckets": Schema(
""" """
request = { request = {
share-numbers: #6.258([* uint]) share-numbers: #6.258([*30 uint])
allocated-size: uint allocated-size: uint
} }
""" """
@ -267,13 +269,15 @@ _SCHEMAS = {
""" """
request = { request = {
"test-write-vectors": { "test-write-vectors": {
* share_number: { ; TODO Add length limit here, after
"test": [* {"offset": uint, "size": uint, "specimen": bstr}] ; https://github.com/anweiss/cddl/issues/128 is fixed
"write": [* {"offset": uint, "data": bstr}] * share_number => {
"test": [*30 {"offset": uint, "size": uint, "specimen": bstr}]
"write": [*30 {"offset": uint, "data": bstr}]
"new-length": uint / null "new-length": uint / null
} }
} }
"read-vector": [* {"offset": uint, "size": uint}] "read-vector": [*30 {"offset": uint, "size": uint}]
} }
share_number = uint share_number = uint
""" """