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

v3: Enhance RestClient to support a key-value object of query parameters #1872

Closed
zFernand0 opened this issue Apr 24, 2023 · 1 comment
Closed
Labels
enhancement New feature or request priority-medium Not functioning - next quarter if capacity permits wontfix This will not be worked on
Milestone

Comments

@zFernand0
Copy link
Member

Benefits
Passing an object for query parameters instead of making everyone construct the entire endpoint has several benefits:

  1. Simplifies the construction of the endpoint: Constructing an entire endpoint can be cumbersome and error-prone, especially if the endpoint has many query parameters. By passing an object for query parameters, the user only needs to create a single object, which can be easily modified and extended.
  2. Increases readability: Passing an object for query parameters can make the code more readable and self-explanatory. The name of the properties in the object can give a clear indication of what each parameter is for.
  3. Facilitates extensibility: When new query parameters need to be added, it is much easier to add a new property to an existing object than to modify the entire endpoint. This makes the code more modular and facilitates extensibility.
  4. Reduces the risk of errors: When constructing an entire endpoint, there is a higher risk of making mistakes, such as typos, missing or misplaced parameters, etc. By passing an object for query parameters, the risk of errors is reduced since the object is validated before being passed to the endpoint.
  5. Simplifies testing: Testing an endpoint with many query parameters can be challenging, especially if each parameter has many possible values. By passing an object for query parameters, it is much easier to test the endpoint since the object can be easily modified and different test cases can be created by changing the values of the properties.

Here is a small python example that may help illustrate the idea.

>>> requests.get(
...     'https://api.github.com/search/repositories',
...     params={'q': 'requests+language:python'}
... )

Source: https://realpython.com/lessons/query-string-parameters/

@zFernand0 zFernand0 added enhancement New feature or request priority-medium Not functioning - next quarter if capacity permits v3 prospective changes for v3 labels Apr 24, 2023
@zFernand0 zFernand0 added this to the Zowe V3 milestone Apr 25, 2023
@awharn awharn transferred this issue from zowe/imperative Nov 13, 2023
@adam-wolfe adam-wolfe mentioned this issue Nov 20, 2023
26 tasks
@t1m0thyj t1m0thyj moved this to Medium Priority in Zowe CLI Squad Dec 26, 2023
@traeok
Copy link
Member

traeok commented Jan 8, 2024

Something to consider before implementation is the potential for an extender or user to inject/pollute query parameters using this type of feature. See this presentation for examples of query pollution: https://owasp.org/www-pdf-archive/AppsecEU09_CarettoniDiPaola_v0.8.pdf

If we plan to implement this feature, we should sanitize the query parameters as much as possible to prevent users from chaining unwanted parameters or delimiting the query. Otherwise, we could be opening ourselves up to API vulnerabilities.

@JTonda JTonda removed the v3 prospective changes for v3 label Feb 14, 2024
@adam-wolfe adam-wolfe mentioned this issue Feb 26, 2024
23 tasks
@JTonda JTonda added the wontfix This will not be worked on label Apr 4, 2024
@JTonda JTonda closed this as not planned Won't fix, can't repro, duplicate, stale Apr 4, 2024
@github-project-automation github-project-automation bot moved this from Medium Priority to Closed in Zowe CLI Squad Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority-medium Not functioning - next quarter if capacity permits wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants