Avoid prototype-polluting assignments in local data providers#11227
Merged
ThieryMichel merged 12 commits intomasterfrom Apr 3, 2026
Merged
Avoid prototype-polluting assignments in local data providers#11227ThieryMichel merged 12 commits intomasterfrom
ThieryMichel merged 12 commits intomasterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses prototype-pollution risks reported by code scanning in the local data providers by routing resource collection writes through safer helpers and adding regression tests for safe collection creation and invalid resource keys.
Changes:
- Replace dynamic
data[resource] = []anddata[resource][index] = ...mutations with safer collection accessors (getResourceCollection,getOrCreateResourceCollection) and array mutation helpers. - Apply the same approach to both
ra-data-local-storageandra-data-local-forageproviders for create/update/delete flows. - Add new unit tests covering safe creation of missing collections and rejection of unsafe resource keys.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| packages/ra-data-local-storage/src/index.ts | Routes write operations through validated resource collections and avoids direct prototype-polluting assignments. |
| packages/ra-data-local-storage/src/index.spec.ts | Adds regression tests for safe collection creation and unsafe resource key rejection. |
| packages/ra-data-local-forage/src/index.ts | Mirrors the safer collection write approach for localForage-backed storage. |
| packages/ra-data-local-forage/src/index.spec.ts | Adds regression tests for safe collection creation and unsafe resource key rejection. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
249ebba to
2dcb9b3
Compare
ThieryMichel
requested changes
Mar 31, 2026
Contributor
ThieryMichel
left a comment
There was a problem hiding this comment.
A simpler and more straightforward fix would be to check that resource === 'proto' and throw an error when it is.
Also add comment to explain the reason.
Need to see if this will content codeql though
65deef8 to
9e5ed65
Compare
slax57
requested changes
Apr 2, 2026
9e5ed65 to
3592005
Compare
slax57
approved these changes
Apr 3, 2026
ThieryMichel
approved these changes
Apr 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Why
GitHub code scanning reports four
Prototype-polluting assignmentalerts:These alerts are false positive since we check resource name on all resources
Added tests to on the check
Testing
yarn test-unit --runTestsByPath packages/ra-data-local-storage/src/index.spec.ts packages/ra-data-local-forage/src/index.spec.ts