-
-
Notifications
You must be signed in to change notification settings - Fork 204
feat: remove support for client packages #2172
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
Conversation
|
🦋 Changeset detectedLatest commit: cfc0abb The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
commit: |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2172 +/- ##
==========================================
+ Coverage 22.49% 24.80% +2.31%
==========================================
Files 273 293 +20
Lines 25634 27595 +1961
Branches 950 1242 +292
==========================================
+ Hits 5766 6845 +1079
- Misses 19862 20742 +880
- Partials 6 8 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
if (config.key) { | ||
const field = map.get(config.key)!; | ||
const name = field.map || config.key; | ||
(params[field.in] as Record<string, unknown>)[name] = arg; |
Check warning
Code scanning / CodeQL
Prototype-polluting assignment Medium
library input
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 month ago
To fix the issue, we need to ensure that untrusted keys such as __proto__
, constructor
, and prototype
cannot be used as property names in the assignment (params[field.in] as Record<string, unknown>)[name] = arg
. This can be achieved by validating the fields
parameter and rejecting or sanitizing any keys that could lead to prototype pollution. Alternatively, we can use a safer data structure, such as Map
, to store the params
object, as Map
does not allow prototype pollution.
The best approach in this case is to validate the keys before performing the assignment. This ensures compatibility with the existing code structure while preventing prototype pollution.
-
Copy modified lines R102-R104 -
Copy modified lines R130-R132
@@ -101,3 +101,5 @@ | ||
const name = field.map || config.key; | ||
(params[field.in] as Record<string, unknown>)[name] = arg; | ||
if (name !== '__proto__' && name !== 'constructor' && name !== 'prototype') { | ||
(params[field.in] as Record<string, unknown>)[name] = arg; | ||
} | ||
} else { | ||
@@ -127,3 +129,5 @@ | ||
if (allowed) { | ||
(params[slot as Slot] as Record<string, unknown>)[key] = value; | ||
if (key !== '__proto__' && key !== 'constructor' && key !== 'prototype') { | ||
(params[slot as Slot] as Record<string, unknown>)[key] = value; | ||
} | ||
break; |
|
||
if (field) { | ||
const name = field.map || key; | ||
(params[field.in] as Record<string, unknown>)[name] = value; |
Check warning
Code scanning / CodeQL
Prototype-polluting assignment Medium
library input
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 month ago
To fix the issue, we need to ensure that keys derived from untrusted input cannot pollute the Object.prototype
. This can be achieved by validating or sanitizing keys before using them in assignments. Specifically, we can check for dangerous keys like __proto__
, constructor
, and prototype
and reject or skip them. Alternatively, we can use a prototype-less object (Object.create(null)
) for params
to eliminate the risk of prototype pollution entirely.
The best approach here is to create params
as a prototype-less object using Object.create(null)
. This ensures that even if a malicious key like __proto__
is used, it will not affect Object.prototype
. Additionally, we will add a safeguard to skip dangerous keys during the assignment process.
-
Copy modified lines R79-R82 -
Copy modified lines R112-R114 -
Copy modified lines R130-R132
@@ -78,6 +78,6 @@ | ||
const params: Params = { | ||
body: {}, | ||
headers: {}, | ||
path: {}, | ||
query: {}, | ||
body: Object.create(null), | ||
headers: Object.create(null), | ||
path: Object.create(null), | ||
query: Object.create(null), | ||
}; | ||
@@ -111,3 +111,5 @@ | ||
const name = field.map || key; | ||
(params[field.in] as Record<string, unknown>)[name] = value; | ||
if (name !== '__proto__' && name !== 'constructor' && name !== 'prototype') { | ||
(params[field.in] as Record<string, unknown>)[name] = value; | ||
} | ||
} else { | ||
@@ -127,3 +129,5 @@ | ||
if (allowed) { | ||
(params[slot as Slot] as Record<string, unknown>)[key] = value; | ||
if (key !== '__proto__' && key !== 'constructor' && key !== 'prototype') { | ||
(params[slot as Slot] as Record<string, unknown>)[key] = value; | ||
} | ||
break; |
727ccd8
to
ba08fb3
Compare
@@ -2,11 +2,11 @@ | |||
import path from 'node:path'; | |||
|
|||
// @ts-ignore | |||
import { customClientPlugin } from '@hey-api/client-custom/plugin'; | |||
import { customClientPlugin } from '@hey-api/custom-client/plugin'; |
Check notice
Code scanning / CodeQL
Unused variable, import, function or class Note test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 month ago
To fix the issue, we will remove the unused customClientPlugin
import from line 5. This will eliminate the flagged error and improve the readability of the code. No other changes are necessary since the import is not used anywhere in the file.
@@ -3,4 +3,2 @@ | ||
|
||
// @ts-ignore | ||
import { customClientPlugin } from '@hey-api/custom-client/plugin'; | ||
import { defineConfig } from '@hey-api/openapi-ts'; |
ba08fb3
to
f2cf721
Compare
f2cf721
to
cfc0abb
Compare
Hi @mrlubos, after updating to @hey-api/openapi-ts@0.73.0, I noticed that the @hey-api/client-* packages are now added directly into the codebase. This seems to allow for faster installation in most cases—thank you for that! However, the source code under client/* and core/* is causing type errors with my current project settings, which prevents me from bundling it. While I could resolve this by modifying my tsconfig.json, I’d prefer to avoid potential side effects without fully verifying them. Would it be possible to include pre-bundled client.js and client.d.ts files for each @hey-api/client-* package? |
@johnny-mh Can you open a new issue with your tsconfig? I'll fix the types/errors so you'd be able to build the client yourself |
@mrlubos I moved the generated files to another package in my monorepo and copied the openapi-ts/tsconfig.json file. After that, everything built successfully without type errors. I believe that if you change your code to match my tsconfig.json, other projects might run into the same issue. I’ll open an issue if I encounter any other problems. Thanks again! |
Please open an issue with your config anyway! |
Okay I’ll open issue tomorrow |
Is there still a possibility to keep using the packages? We now have the |
Yeah, I was very reluctant to upgrade past this version. To echo @KiwiKilian , in our use case, we generate multiple clients which would lead to a lot of duplicated code. We need some way to allow for multiple generated clients to share the same core code. Not to mention that I'm not really a fan of having all this generated core code in our codebase, id much rather it live in the package like it used to... but I could look past that if this issue is fixed. |
@kylecarhart definitely feel free to not upgrade and stay pinned on an older version! But please, please let me know why so I can figure out a way to make both you and me happy with these features 🤝 I'll get to these clients again, it's on my radar |
Closes #1969
Closes #1821
Closes #1660