Language: Python
Label: safe
CWE: CWE-770 \u2014 Allocation of Resources Without Limits or Throttling
The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor.

Code:
def parse_body(body: bytes, boundary: bytes, multipart_form_part_limit: int) -> List[bytes]:
    """Split the body using the boundary
        and validate the number of form parts is within the allowed limit.

    :param body: The form body.
    :param boundary: The boundary used to separate form components.
    :param multipart_form_part_limit: The limit of allowed form components
    :return:
        A list of form components.
    """
    if not (body and boundary):
        return []

    form_parts = body.split(boundary, multipart_form_part_limit + 3)[1:-1]

    if len(form_parts) > multipart_form_part_limit:
        raise ValidationException(
            f"number of multipart components exceeds the allowed limit of {multipart_form_part_limit}, "
            f"this potentially indicates a DoS attack"
        )

    return form_parts