lus / pasty

pasty is a fast and lightweight code pasting server
https://pasty.lus.pm
MIT License
200 stars 28 forks source link

Add content length cap for paste creation endpoint #8

Closed zekroTJA closed 3 years ago

zekroTJA commented 3 years ago

This pull request adds a new configuration value named LENGTH_CAP (which defaults to 50000). On request to the POST /v1/pastes, the content length header is read and compared with this config value, if it is larger than 0. If the content length is larger than the defined cap, a 400 Bad Request response with the content request body length overflow is returned.

This pull request fixes #7.

lus commented 3 years ago

Thanks for your pull request. I did some additional changes and fixes that came across during testing but these were because of my shitty codebase. I will start implementing this in the staging branch and thus deploying it on https://paste.pelkum.dev.