Repository navigation
Remove $FlowFixMe from __proto__ JSON test - #2203
Merged
Merged
Conversation
Replace the `$FlowFixMe` annotation on the evaluated JSON module value with a runtime refinement of `unknown`: throw unless the export is a non-null object. Check for prototype pollution with `'x' in value` instead of reading the untyped `value.x`: `in` also sees inherited properties, so it catches a polluted prototype, and unlike a `getPrototypeOf` identity comparison it works across the Jest vm realm boundary. The `Object.keys` assertion is unchanged.
vzaidman
commented
Nov 9, 2026
|
|
||
| const value: $FlowFixMe = evaluateJsonModule(sources[0]); | ||
| const value = evaluateJsonModule(sources[0]); | ||
| if (typeof value !== 'object' || value === null) { |
Contributor
Author
There was a problem hiding this comment.
this warning is expected
robhogan
approved these changes
Nov 9, 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
Follow-up to #2199. The
__proto__JSON test annotated the evaluated module value as$FlowFixMewith no justification. This replaces the suppression with a runtime refinement ofunknown: throw unless the export is a non-null object.The prototype-pollution check is
expect('x' in value).toBe(false)instead of reading the untypedvalue.x.inalso sees inherited properties, so it catches a polluted prototype, and unlike agetPrototypeOfidentity comparison it works across the Jest vm realm boundary (the evaluated value is created in another realm, so its prototype is not identical to the test file'sObject.prototype). Avalue as {[key: string]: unknown}cast is not an option: Flow rejects castingunknownto the indexer type.The
Object.keysassertion is unchanged.Test plan
ESLint and Prettier on the changed file are clean. I also verified the new assertion fails if
jsonToCommonJSgoes back to emitting the object literal.