Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

detect-child-process TypeError: Cannot read property 'type' of undefined #31

Closed
nestoru opened this issue May 28, 2018 · 4 comments
Closed

Comments

@nestoru
Copy link

nestoru commented May 28, 2018

Unless I use the below:

"rules": {
    "security/detect-child-process": "off"
 }

The linter fails with:

$ eslint --no-eslintrc -c ~/Downloads/eslint-4.json ~/workspace/lms-spa/app/
Cannot read property 'type' of undefined
TypeError: Cannot read property 'type' of undefined
at MemberExpression (/usr/local/lib/node_modules/eslint-plugin-security/rules/detect-child-process.js:34:87)
at listeners.(anonymous function).forEach.listener (/usr/local/lib/node_modules/eslint/lib/util/safe-emitter.js:47:58)
at Array.forEach ()
at Object.emit (/usr/local/lib/node_modules/eslint/lib/util/safe-emitter.js:47:38)
at NodeEventGenerator.applySelector (/usr/local/lib/node_modules/eslint/lib/util/node-event-generator.js:251:26)
at NodeEventGenerator.applySelectors (/usr/local/lib/node_modules/eslint/lib/util/node-event-generator.js:280:22)
at NodeEventGenerator.enterNode (/usr/local/lib/node_modules/eslint/lib/util/node-event-generator.js:294:14)
at CodePathAnalyzer.enterNode (/usr/local/lib/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:608:23)
at Traverser.enter [as _enter] (/usr/local/lib/node_modules/eslint/lib/linter.js:865:28)
at Traverser._traverse (/usr/local/lib/node_modules/eslint/lib/util/traverser.js:132:14)

Is this a known issue with detect-child-process ?

@lionello
Copy link

lionello commented Jun 6, 2018

Same here, got triggered on a .exec().

@lionello
Copy link

lionello commented Jun 6, 2018

https://github.com/nodesecurity/eslint-plugin-security/blob/b72890b2b97245cf40a10a6ddb13918aad57790c/rules/detect-child-process.js#L22

This line causes the #31 for me because it ended up adding undefined to the names array. Changing the line to check for a valid name fixes this:

                 var args = node.arguments[0];
                 if (args && args.type === 'Literal' && args.value === 'child_process') {
-                    if (node.parent.type === 'VariableDeclarator') {
+                    if (node.parent.type === 'VariableDeclarator' && node.parent.id.name) {
                         names.push(node.parent.id.name);
                     } else if (node.parent.type === 'AssignmentExpression' && node.parent.operator === '=') {

@sergio-domingues
Copy link

any updates on this ?

@ota-meshi
Copy link
Member

I checked past source code and this is the same issue as #69. That's fixed in #97.
So I will close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants