Skip to content

Conversation

@odesenfans
Copy link
Collaborator

Problem: the posts.json endpoint is too permissive and allows users to specify invalid hashes, time filters, pagination, etc.

Solution: detect these cases and return a 422 error.

Replaced the validation code by a Pydantic model.

Breaking changes:

  • The "endDate" field is now considered as exclusive.

Moreover, a 422 error code will now be returned in the following situations, where the previous implementation would simply return a 200:

  • if an invalid item hash (=not a hexadecimal sha256, CIDv0 or CIDv1) is specified in the "hashes" or "contentHashes" field.
  • if the "endDate" field is lower than the "startDate" field.
  • if "endDate" or "startDate" are negative.
  • if pagination parameters ("page" and "pagination") are negative.

Problem: the posts.json endpoint is too permissive and allows users
to specify invalid hashes, time filters, pagination, etc.

Solution: detect these cases and return a 422 error.

Replaced the validation code by a Pydantic model.

Breaking changes:
* The "endDate" field is now considered as exclusive.

Moreover, a 422 error code will now be returned in the following
situations, where the previous implementation would simply return a 200:

* if an invalid item hash (=not a hexadecimal sha256, CIDv0 or CIDv1)
  is specified in the "hashes" or "contentHashes" field.
* if the "endDate" field is lower than the "startDate" field.
* if "endDate" or "startDate" are negative.
* if pagination parameters ("page" and "pagination") are negative.
@odesenfans odesenfans requested a review from hoh October 14, 2022 10:46
@odesenfans odesenfans merged commit 1bc15fe into aleph-im:dev Oct 14, 2022
@odesenfans odesenfans deleted the od-use-pydantic-in-posts-api branch October 14, 2022 12:21
odesenfans added a commit that referenced this pull request Oct 17, 2022
Problem: the posts.json endpoint is too permissive and allows users
to specify invalid hashes, time filters, pagination, etc.

Solution: detect these cases and return a 422 error.

Replaced the validation code by a Pydantic model.

Breaking changes:
* The "endDate" field is now considered as exclusive.

Moreover, a 422 error code will now be returned in the following
situations, where the previous implementation would simply return a 200:

* if an invalid item hash (=not a hexadecimal sha256, CIDv0 or CIDv1)
  is specified in the "hashes" or "contentHashes" field.
* if the "endDate" field is lower than the "startDate" field.
* if "endDate" or "startDate" are negative.
* if pagination parameters ("page" and "pagination") are negative.
odesenfans added a commit that referenced this pull request Oct 27, 2022
Problem: the posts.json endpoint is too permissive and allows users
to specify invalid hashes, time filters, pagination, etc.

Solution: detect these cases and return a 422 error.

Replaced the validation code by a Pydantic model.

Breaking changes:
* The "endDate" field is now considered as exclusive.

Moreover, a 422 error code will now be returned in the following
situations, where the previous implementation would simply return a 200:

* if an invalid item hash (=not a hexadecimal sha256, CIDv0 or CIDv1)
  is specified in the "hashes" or "contentHashes" field.
* if the "endDate" field is lower than the "startDate" field.
* if "endDate" or "startDate" are negative.
* if pagination parameters ("page" and "pagination") are negative.
odesenfans added a commit that referenced this pull request Jan 9, 2023
Problem: the posts.json endpoint is too permissive and allows users
to specify invalid hashes, time filters, pagination, etc.

Solution: detect these cases and return a 422 error.

Replaced the validation code by a Pydantic model.

Breaking changes:
* The "endDate" field is now considered as exclusive.

Moreover, a 422 error code will now be returned in the following
situations, where the previous implementation would simply return a 200:

* if an invalid item hash (=not a hexadecimal sha256, CIDv0 or CIDv1)
  is specified in the "hashes" or "contentHashes" field.
* if the "endDate" field is lower than the "startDate" field.
* if "endDate" or "startDate" are negative.
* if pagination parameters ("page" and "pagination") are negative.
odesenfans added a commit that referenced this pull request Mar 21, 2023
Problem: the posts.json endpoint is too permissive and allows users
to specify invalid hashes, time filters, pagination, etc.

Solution: detect these cases and return a 422 error.

Replaced the validation code by a Pydantic model.

Breaking changes:
* The "endDate" field is now considered as exclusive.

Moreover, a 422 error code will now be returned in the following
situations, where the previous implementation would simply return a 200:

* if an invalid item hash (=not a hexadecimal sha256, CIDv0 or CIDv1)
  is specified in the "hashes" or "contentHashes" field.
* if the "endDate" field is lower than the "startDate" field.
* if "endDate" or "startDate" are negative.
* if pagination parameters ("page" and "pagination") are negative.
odesenfans added a commit that referenced this pull request Mar 21, 2023
Problem: the posts.json endpoint is too permissive and allows users
to specify invalid hashes, time filters, pagination, etc.

Solution: detect these cases and return a 422 error.

Replaced the validation code by a Pydantic model.

Breaking changes:
* The "endDate" field is now considered as exclusive.

Moreover, a 422 error code will now be returned in the following
situations, where the previous implementation would simply return a 200:

* if an invalid item hash (=not a hexadecimal sha256, CIDv0 or CIDv1)
  is specified in the "hashes" or "contentHashes" field.
* if the "endDate" field is lower than the "startDate" field.
* if "endDate" or "startDate" are negative.
* if pagination parameters ("page" and "pagination") are negative.
This was referenced Apr 14, 2023
odesenfans added a commit that referenced this pull request Apr 24, 2023
Problem: the posts.json endpoint is too permissive and allows users
to specify invalid hashes, time filters, pagination, etc.

Solution: detect these cases and return a 422 error.

Replaced the validation code by a Pydantic model.

Breaking changes:
* The "endDate" field is now considered as exclusive.

Moreover, a 422 error code will now be returned in the following
situations, where the previous implementation would simply return a 200:

* if an invalid item hash (=not a hexadecimal sha256, CIDv0 or CIDv1)
  is specified in the "hashes" or "contentHashes" field.
* if the "endDate" field is lower than the "startDate" field.
* if "endDate" or "startDate" are negative.
* if pagination parameters ("page" and "pagination") are negative.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants