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

paramsFromClient pollutes context by default #730

Open
FossPrime opened this issue Aug 30, 2023 · 1 comment · May be fixed by #764
Open

paramsFromClient pollutes context by default #730

FossPrime opened this issue Aug 30, 2023 · 1 comment · May be fixed by #764

Comments

@FossPrime
Copy link
Contributor

FossPrime commented Aug 30, 2023

delete params.query.$client;

While whitelisting is a good security feature, it is the adapter's job to complain about invalid query parameters, not ours.

It makes it difficult to compose hooks with this as it damages the context if used at app level/around/provider and also in services.

Proposal:

   const foreignParamCount = 0
    // in an Object.keys(ctx.params.query?.$client) loop, foreignParamCount++
	if (foreignParamCount === 0) {
      delete ctx.params.query.$client
    }

The alternative is to dump repetitive code like this in all over userland hooks:

delete ctx.params.query.$client.sudo
if (Object.keys(ctx.params.query.$client).length === 0) {
  delete ctx.params.query.$client
}
@fratzinger
Copy link
Collaborator

Just a quick headsup. I started working on a massive rewrite of the package (#764). It's not released yet and will take a few weeks.

This should be fine then, see https://github.com/feathersjs-ecosystem/feathers-hooks-common/blob/modernize/src/hooks/params-from-client2/params-from-client2.ts

@fratzinger fratzinger linked a pull request Feb 18, 2025 that will close this issue
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 a pull request may close this issue.

2 participants