-
-
Notifications
You must be signed in to change notification settings - Fork 826
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
Fix for code scanning alert no. 29: Prototype-polluting assignment #7028
Conversation
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Caution Review failedThe pull request is closed. 📝 WalkthroughSummary by CodeRabbit
WalkthroughThe pull request enhances the Changes
Possibly related PRs
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 ESLint
packages/merge/src/merge-resolvers.tsOops! Something went wrong! :( ESLint: 9.22.0 ESLint couldn't find an eslint.config.(js|mjs|cjs) file. From ESLint v9.0.0, the default configuration file is now eslint.config.js. https://eslint.org/docs/latest/use/configure/migration-guide If you still have problems after following the migration guide, please stop by Tip ⚡🧪 Multi-step agentic review comment chat (experimental)
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/merge/src/merge-resolvers.ts (1)
75-77
: Good security fix for prototype pollution vulnerability.This change effectively addresses the prototype pollution vulnerability by preventing the deletion of special JavaScript properties (
__proto__
,constructor
, andprototype
) from the merged result object. The solution aligns perfectly with the PR objective of fixing code scanning alert no. 29.One small suggestion for improvement: consider extracting the array of protected property names into a constant to avoid repeating it twice in the conditional check, improving maintainability.
+const PROTECTED_PROPS = ['__proto__', 'constructor', 'prototype']; if (options?.exclusions) { for (const exclusion of options.exclusions) { const [typeName, fieldName] = exclusion.split('.'); - if (['__proto__', 'constructor', 'prototype'].includes(typeName) || ['__proto__', 'constructor', 'prototype'].includes(fieldName)) { + if (PROTECTED_PROPS.includes(typeName) || PROTECTED_PROPS.includes(fieldName)) { continue; }
🚀 Snapshot Release (
|
Package | Version | Info |
---|---|---|
@graphql-tools/executor-urql-exchange |
1.0.18-alpha-20250313124350-d2b263d5c7f8376f95fa3c5bf725e4b6815da646 |
npm ↗︎ unpkg ↗︎ |
@graphql-tools/graphql-tag-pluck |
8.3.18-alpha-20250313124350-d2b263d5c7f8376f95fa3c5bf725e4b6815da646 |
npm ↗︎ unpkg ↗︎ |
graphql-tools |
9.0.17-alpha-20250313124350-d2b263d5c7f8376f95fa3c5bf725e4b6815da646 |
npm ↗︎ unpkg ↗︎ |
@graphql-tools/load |
8.0.18-alpha-20250313124350-d2b263d5c7f8376f95fa3c5bf725e4b6815da646 |
npm ↗︎ unpkg ↗︎ |
@graphql-tools/code-file-loader |
8.1.19-alpha-20250313124350-d2b263d5c7f8376f95fa3c5bf725e4b6815da646 |
npm ↗︎ unpkg ↗︎ |
@graphql-tools/git-loader |
8.0.23-alpha-20250313124350-d2b263d5c7f8376f95fa3c5bf725e4b6815da646 |
npm ↗︎ unpkg ↗︎ |
@graphql-tools/github-loader |
8.0.19-alpha-20250313124350-d2b263d5c7f8376f95fa3c5bf725e4b6815da646 |
npm ↗︎ unpkg ↗︎ |
@graphql-tools/merge |
9.0.23-alpha-20250313124350-d2b263d5c7f8376f95fa3c5bf725e4b6815da646 |
npm ↗︎ unpkg ↗︎ |
@graphql-tools/mock |
9.0.21-alpha-20250313124350-d2b263d5c7f8376f95fa3c5bf725e4b6815da646 |
npm ↗︎ unpkg ↗︎ |
@graphql-tools/node-require |
7.0.19-alpha-20250313124350-d2b263d5c7f8376f95fa3c5bf725e4b6815da646 |
npm ↗︎ unpkg ↗︎ |
@graphql-tools/relay-operation-optimizer |
7.0.18-alpha-20250313124350-d2b263d5c7f8376f95fa3c5bf725e4b6815da646 |
npm ↗︎ unpkg ↗︎ |
@graphql-tools/schema |
10.0.22-alpha-20250313124350-d2b263d5c7f8376f95fa3c5bf725e4b6815da646 |
npm ↗︎ unpkg ↗︎ |
🦋 Changeset detectedLatest commit: d2b263d The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
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 |
💻 Website PreviewThe latest changes are available as preview in: https://c14c0c7c.graphql-tools.pages.dev |
Potential fix for https://github.com/ardatan/graphql-tools/security/code-scanning/29
To fix the prototype pollution vulnerability, we need to ensure that the
typeName
andfieldName
values cannot be special property names like__proto__
,constructor
, orprototype
. We can achieve this by adding a validation step before using these values to delete properties from theresult
object.The best way to fix this problem without changing existing functionality is to add a check to ensure that
typeName
andfieldName
are not one of the special property names. If they are, we should skip the deletion operation.Suggested fixes powered by Copilot Autofix. Review carefully before merging.