Skip to content

aggregator(cost-explorer): null-prototype setups store (#2851) - #3491

Merged
dezren39 merged 1 commit into
mainfrom
queue/5444-2851-proto-store
Nov 1, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/5444-2851-proto-store

Conversation

@dezren39

@dezren39 dezren39 commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Fixes #2851.

Problem

The cost-explorer saved-setups store keyed setups by name in a plain JSON.parse'd object. A setup named __proto__ assigned the store's prototype instead of becoming an entry — silently never saved — and importing a setups file with a __proto__ entry mutated the live store object's prototype (its fields leaked into reads) while the entry itself was dropped on store. Confirmed by triage task 4018 probe re-runs on current main.

Fix (pinned by triage)

loadSetups() now copies the parsed object's own keys into Object.create(null) and returns that; the parse-failure fallback is likewise a null-prototype empty store. On a null-prototype object, the save handler's all[name] = ... and the import handler's all[k] = ... create ordinary own entries for every name including __proto__; JSON.stringify/Object.keys behave as before, and there is no prototype to mutate. No name is rejected and no other handler changes.

Tests

New pm-stack/aggregator/test/setups-store-2851.test.ts extracts the shipped loadSetups/storeSetups from src/render.ts and drives the verbatim save/import handler cores against a stub localStorage:

  • __proto__ setup saves, reloads, and exports as a real own entry
  • importing raw {"__proto__": {...}, "Real": {...}} stores both as entries, store prototype is null, nothing leaks into unrelated objects
  • controls constructor / toString / ordinary unchanged

4/4 pass with the fix; 3/4 fail on unfixed code. Full aggregator suite: 238 pass / 37 fail / 30 errors vs clean-main baseline 234 / 37 / 30 — identical pre-existing failures, +4 new passes, zero regressions.

Queue task 5444 (repo-health-code-pilot), Lane D.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

loadSetups() returned the JSON.parse result directly, so a setup named __proto__ assigned the store prototype instead of becoming an entry (silently never saved), and an imported __proto__ entry mutated the live store prototype while being dropped. loadSetups now copies parsed own keys into Object.create(null); save/import/export handlers unchanged. Regression test extracts the shipped loadSetups/storeSetups and drives the save/import cores over the __proto__/constructor/toString/ordinary matrix.
@dezren39
dezren39 requested a review from a team as a code owner November 1, 2026 10:26
@coderabbitai

coderabbitai Bot commented Nov 1, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 30 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 12e98146-3892-42e6-85ab-ac42204af347
Commits

Reviewing files that changed from the base of the PR and between d212087 and 279f832.

Files selected for processing: 2
  • pm-stack/aggregator/src/render.ts
  • pm-stack/aggregator/test/setups-store-2851.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T10:27:21.499887Z 279f832 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant