Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[http] Validate request parameters #29

Closed
ghost opened this issue Oct 20, 2019 · 4 comments
Closed

[http] Validate request parameters #29

ghost opened this issue Oct 20, 2019 · 4 comments
Labels
c-http Affects the http crate t-feature Addition of a new feature

Comments

@ghost
Copy link

ghost commented Oct 20, 2019

Validate that request parameters and body values are within the accepted ranges. For example, getting some members from a guild can only get at most 1000 at a time. This will help prevent as many 400s as we can.

@ghost ghost added t-feature Addition of a new feature c-http Affects the http crate labels Oct 20, 2019
@ghost ghost added this to the 0.1 milestone Oct 20, 2019
@github-actions
Copy link
Contributor

This issue has been marked as stale because it has been open with no activity for 60 days. It will be closed in 5 days unless a comment triages the issue.

@github-actions github-actions bot added the Stale label Dec 20, 2019
@Erk-
Copy link
Member

Erk- commented Dec 20, 2019

Still missing, but is not a blocker

@Erk- Erk- reopened this Dec 26, 2019
@Erk- Erk- removed the Stale label Dec 27, 2019
@github-actions
Copy link
Contributor

This issue has been marked as stale because it has been open with no activity for 60 days. It will be closed in 5 days unless a comment triages the issue.

@github-actions github-actions bot added the Stale label Feb 26, 2020
@Erk- Erk- removed the Stale label Feb 26, 2020
@zeylahellyer zeylahellyer self-assigned this Apr 17, 2020
zeylahellyer added a commit that referenced this issue May 26, 2020
http: validate request parameters

This patch is a continuation of PR #146 with the comments applied.

When creating HTTP requests, validate the request parameters. This
includes things like checking that the content length of a message is
less than or equal to 2000 characters[1], that a new channel's name is
within the range of 2-100 characters[2], and more.

The request methods that do validation now return results with an error
type that is local to the module. For example, the
`http::request::channel::UpdateChannel::name` method can return an
error, which is defined at
`http::request::channel::update_channel::UpdateChannelError`.

Validation functions are located in `http::request::validation`, which
includes functions that simply return booleans of whether the input is
valid or not. Each of these sources where the validation limits are
documented. Some things, such as custom emoji names, don't have a
documented length limit[3], so validation isn't done for them.

[1]: https://discordapp.com/developers/docs/resources/channel#create-message-params
[2]: https://discordapp.com/developers/docs/resources/channel#channel-object-channel-structure
[3]: https://discordapp.com/developers/docs/resources/emoji#create-guild-emoji-json-params

Closes issue #29.

Approved-by: Erk-
Merged-by: Vivian Hellyer <vivian@hellyer.dev>
Signed-off-by: Vivian Hellyer <vivian@hellyer.dev>
@zeylahellyer
Copy link
Member

Closed by #167

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c-http Affects the http crate t-feature Addition of a new feature
Projects
None yet
Development

No branches or pull requests

2 participants