Callback parameter needs an extra check
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- javascript
- Domain
- tooling
Research direction
Reproduce the supplied callback example with the static-eval entry point and inspect index.js around line 134, where the stack trace shows the property access failure. Trace how callback arguments are passed into the evaluator, then add a regression test covering the provided object input and verify that it completes without the reported TypeError.
Written by the indexing model from the issue text.
Description
My test code looks like this:
var evaluate = require('static-eval');
var parse = require('esprima').parse;
var src = 'foo(function (obj) { return obj.x })';
var ast = parse(src).body[0].expression;
var result = evaluate(ast, {
foo: function (func) {
return func({x: 1})
},
});
console.log(result);
When I run it, I get:
$ node test.js
/home/stathis/src/jellyfish-jellyscript/node_modules/static-eval/index.js:134
return obj[node.property.name];
^
TypeError: Cannot read property 'x' of null
at walk (/home/stathis/src/jellyfish-jellyscript/node_modules/static-eval/index.js:134:27)
at walk (/home/stathis/src/jellyfish-jellyscript/node_modules/static-eval/index.js:152:20)
at walk (/home/stathis/src/jellyfish-jellyscript/node_modules/static-eval/index.js:171:20)
at walk (/home/stathis/src/jellyfish-jellyscript/node_modules/static-eval/index.js:112:25)
at module.exports (/home/stathis/src/jellyfish-jellyscript/node_modules/static-eval/index.js:204:7)
at Object.<anonymous> (/home/stathis/src/jellyfish-jellyscript/test.js:6:14)
at Module._compile (internal/modules/cjs/loader.js:1068:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:933:32)
at Function.Module._load (internal/modules/cjs/loader.js:774:14)
whereas when I change
var src = 'foo(function (obj) { return obj.x })';`
to
var src = 'foo(function (obj) { return obj && obj.x })';`
I get a successful result:
$ node test.js
1
This looks like a bug to me, as my callback's input here is just {x: 1}, why would I need to make sure obj exists?
- Dominant language
- JavaScript
- Stars
- 177
- Forks
- 27
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from browserify/static-eval
-
CVE in word-wrap Open
Difficulty 3/5 1-2 days Newbie friendliness 35/100
browserify/static-eval#42 · 1 comment · 2 reactions ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
browserify/static-eval#41 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
browserify/static-eval#39 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
browserify/static-eval#34 · 20 comments · 3 reactions ·
-
Sandbox Escape Open
Difficulty 5/5 Over a week Newbie friendliness 20/100
browserify/static-eval#32 · 1 comment · 3 reactions ·
All issues in browserify/static-eval
Similar issues
-
area/install-update comp/cli comp/desktop P3 sweeper:risk-compatibility type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
NousResearch/hermes-agent#122386 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
security
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
IBM/node-sdk-core#373 ·
-
docs web/
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100