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

httpd::routes::handle() should verify http param's data type #2082

Open
tchaikov opened this issue Feb 7, 2024 · 0 comments
Open

httpd::routes::handle() should verify http param's data type #2082

tchaikov opened this issue Feb 7, 2024 · 0 comments

Comments

@tchaikov
Copy link
Contributor

tchaikov commented Feb 7, 2024

if an http param's data type is specified, we should verify it. currently, routes::handle() just check if the required parameters exist in the request. but their types are not checked at all. the application is responsible to verify the type of parameters.

would be great if httpd::routes can verify the parameter and even return the parameters using an interface like

http::request::get_query_param_as<int>(std::string_view) const
tchaikov added a commit to tchaikov/seastar that referenced this issue Feb 7, 2024
this member variable should not be exposed to the outer world. it's
a part of the implementation of httpd subsystem.

by marking it private, allows us to store the typing of the params
into `_mandatory_param`.

Refs scylladb#2082
Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
tchaikov added a commit to tchaikov/seastar that referenced this issue Feb 9, 2024
before this change, this member function was a free function called
by `routes::handle()`, but since `handler_base` is closer to the
`_mandatory_param` and in the following change, we will store
the expected param types in `_mandatory_param`, this makes
`handler_base` a better home for the verification function. so to
prepare for the change, let's move this free function into handler_base.

also, let's mark `_mandatory_param` private, allows us to store the
typing of the params into `_mandatory_param`. as this variable should
not be visible from the outer world. and the typing information should
be opaque from the caller.

Refs scylladb#2082
Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
xemul pushed a commit that referenced this issue Feb 9, 2024
before this change, this member function was a free function called
by `routes::handle()`, but since `handler_base` is closer to the
`_mandatory_param` and in the following change, we will store
the expected param types in `_mandatory_param`, this makes
`handler_base` a better home for the verification function. so to
prepare for the change, let's move this free function into handler_base.

also, let's mark `_mandatory_param` private, allows us to store the
typing of the params into `_mandatory_param`. as this variable should
not be visible from the outer world. and the typing information should
be opaque from the caller.

Refs #2082
Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>

Closes #2084
tchaikov added a commit to tchaikov/seastar that referenced this issue Feb 10, 2024
use `join()` to simplify the implementation to print the names of
required query parameters, simpler this way. this change also
prepares for scylladb#2082.

Refs scylladb#2082

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
avikivity added a commit that referenced this issue Feb 18, 2024
…rom Kefu Chai

this change refactors `seastar-json2code.py` by splitting `create_h_file()` into smaller pieces, and also reformats the rendered code with better formatting.

Refs #2082

Closes #2090

* github.com:scylladb/seastar:
  seastar-json2code: collect required_query_params using a list
  seastar-json2code: reduce the indent level
  seastar-json2code: indent the enum and array elements
  seastar-json2code: generate code for enum type using Template
  seastar-json2code: extract add_operation() out
hurricane1026 pushed a commit to clapdb/seastar that referenced this issue Feb 19, 2024
use `join()` to simplify the implementation to print the names of
required query parameters, simpler this way. this change also
prepares for scylladb#2082.

Refs scylladb#2082

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
tchaikov added a commit to tchaikov/seastar that referenced this issue Feb 26, 2024
this change paves the road to scylladb#2082. so that we can store more
properties in the Parameter class in this python script and then
translate them into a C++ class which is used to verify and expose
the content and schema of a parameter. so that they can be used
in `handler_base::verify_mandatory_params()` in a follow-up
change.

Refs scylladb#2082
Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
tchaikov added a commit to tchaikov/seastar that referenced this issue Feb 26, 2024
this change paves the road to scylladb#2082. so that we can store more
properties in the Parameter class in this python script and then
translate them into a C++ class which is used to verify and expose
the content and schema of a parameter. so that they can be used
in `handler_base::verify_mandatory_params()` in a follow-up
change.

Refs scylladb#2082
Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
graphcareful pushed a commit to graphcareful/seastar that referenced this issue Mar 20, 2024
before this change, this member function was a free function called
by `routes::handle()`, but since `handler_base` is closer to the
`_mandatory_param` and in the following change, we will store
the expected param types in `_mandatory_param`, this makes
`handler_base` a better home for the verification function. so to
prepare for the change, let's move this free function into handler_base.

also, let's mark `_mandatory_param` private, allows us to store the
typing of the params into `_mandatory_param`. as this variable should
not be visible from the outer world. and the typing information should
be opaque from the caller.

Refs scylladb#2082
Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>

Closes scylladb#2084
graphcareful pushed a commit to graphcareful/seastar that referenced this issue Mar 20, 2024
use `join()` to simplify the implementation to print the names of
required query parameters, simpler this way. this change also
prepares for scylladb#2082.

Refs scylladb#2082

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
graphcareful pushed a commit to graphcareful/seastar that referenced this issue Mar 20, 2024
…rom Kefu Chai

this change refactors `seastar-json2code.py` by splitting `create_h_file()` into smaller pieces, and also reformats the rendered code with better formatting.

Refs scylladb#2082

Closes scylladb#2090

* github.com:scylladb/seastar:
  seastar-json2code: collect required_query_params using a list
  seastar-json2code: reduce the indent level
  seastar-json2code: indent the enum and array elements
  seastar-json2code: generate code for enum type using Template
  seastar-json2code: extract add_operation() out
tchaikov added a commit to tchaikov/seastar that referenced this issue Apr 3, 2024
this change paves the road to scylladb#2082. so that we can store more
properties in the Parameter class in this python script and then
translate them into a C++ class which is used to verify and expose
the content and schema of a parameter. so that they can be used
in `handler_base::verify_mandatory_params()` in a follow-up
change.

Refs scylladb#2082
Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
xemul added a commit that referenced this issue May 2, 2024
…Kefu Chai

this change paves the road to #2082. so that we can store more
properties in the Parameter class in this python script and then
translate them into a C++ class which is used to verify and expose
the content and schema of a parameter. so that they can be used
in `handler_base::verify_mandatory_params()` in a follow-up
change.

Refs #2082

Closes #2120

* https://github.com/scylladb/seastar:
  seastar-json2code: extract Parameter class
  seastar-json2code: use f-string when appropriate
  seastar-json2code: use nickname in place of oper['nickname']
  seastar-json2code: use dict.get() when checking allowMultiple
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant