fix(hogvm): use own-property checks for nested access and async dispatch#59218
Merged
Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
|
Address review feedback: - Replace the three-name blocklist in getNestedValue with an own-property check, so all inherited keys (toString, valueOf, etc.) consistently return null rather than leaking prototype values. - Use Object.prototype.hasOwnProperty.call for the declaredFunctions lookup in CALL_GLOBAL, matching the pattern already used elsewhere. - Add parametrised tests for getNestedValue (own/missing/inherited keys, Map and array indexing) and for execAsync dispatch rejecting inherited function names. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
common/hogvm/typescript/src/__tests__/execute.test.ts:394-401
**`toString` missing from async dispatch test**
The test array covers `hasOwnProperty`, `constructor`, and `__proto__`, but omits `toString` — the one name explicitly guarded against in the adjacent `declaredFunctions` check (`name !== 'toString'`). Before this PR, `'toString' in ASYNC_STL` evaluated to `true` (inherited), so `toString` was the original motivating case. Adding it here would close the gap and keep the test in sync with the guarded name in the sync path.
Reviews (2): Last reviewed commit: "chore(hogvm): widen own-property checks ..." | Re-trigger Greptile |
mariusandra
approved these changes
May 21, 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.
Problem
A few places in the HogVM TypeScript runtime treat inherited properties the same as own properties:
getNestedValueincommon/hogvm/typescript/src/utils.tsdoes raw bracket access for non-numeric, non-Map keys, so a chain like['__proto__']walks the prototype chain instead of returningnull.common/hogvm/typescript/src/execute.tsuses theinoperator to look upasyncFunctionNameinoptions.asyncFunctionsandASYNC_STL, which also matches inherited keys (toString,constructor, etc.). The sync dispatch path a few hundred lines down already usesObject.hasOwn(ASYNC_STL, ...), so the async paths were the odd ones out.Both behaviors are surprising relative to what the VM is meant to expose. This PR tightens them up.
Changes
getNestedValue: explicitly reject__proto__,constructor, andprototypeas keys when traversing plain objects. Map and numeric-index branches are unchanged.execAsync: replacename in options.asyncFunctionsandname in ASYNC_STLwithObject.prototype.hasOwnProperty.call(...), matching the pattern already used by the sync dispatch site.No behavior change for valid inputs — only inputs that previously resolved against inherited properties now fail cleanly.
How did you test this code?
I'm an agent — no manual testing was performed.
Ran the existing HogVM TypeScript test suites:
npx jest src/__tests__/utils.test.ts src/__tests__/execute.test.tsincommon/hogvm/typescript/— 47/47 passing.Publish to changelog?
no
🤖 Agent context
Authored by Claude (Opus 4.7) at the user's direction. The user pointed at the three affected call sites and asked for the minimal recommended patch — no broader refactor of property-access utilities, STL conversion, or the surrounding execution flow. Considered defense-in-depth changes to
setNestedValueandJSONExtractArrayRawFnbut explicitly scoped them out for this PR.