GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |
GeezerVison is showing github.com — fix(mock): keep a header named __proto__ in snapshots by luantaraschi · Pull Request #5668 · nodejs/undici Conversation
Contributor
This relates to...I raised this in a comment on #5667 and offered to send it separately. Sending it now that #5663 was approved, since it is the same guard on a subsystem where the consequence is different. RationaleThree places in the snapshot mock build a plain object keyed by header name and assign into it:
It does not stop at a lost header. const filters = createHeaderFilters({}) const a = formatRequestKey({ origin, path, method: 'GET', headers: JSON.parse('{"__proto__":"a","x-real":"same"}') }, filters) const b = formatRequestKey({ origin, path, method: 'GET', headers: { 'x-real': 'same' } }, filters) createRequestHash(a) === createRequestHash(b) // true In record mode the two collapse into one entry, and in playback the recorded response for one is served for the other. There is no ChangesA The object stays plain rather than switching to a null prototype, because it is serialized into snapshot files and handed back to user code. After the change the same pair hashes differently and the header survives: One test in
FeaturesN/A Bug FixesA header named Breaking Changes and DeprecationsNone. Status
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsnormalizeHeaders and both header filters assigned into a plain object, so the __proto__ key reached the Object.prototype setter and the header was dropped. formatRequestKey feeds those headers to createRequestHash, so two requests differing only by that header produced the same snapshot key: one entry in record mode, the wrong response in playback. Writes now go through a setHeader helper using Object.defineProperty, the guard parseHeaders already uses.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
This was referenced
|
There was an error while loading. Please reload this page.
|
Folded into #5688, where the guard lives once as Closing this one so your queue stays readable. Happy to reopen it if you would rather look at this site on its own. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.