question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: `Object.prototype` builtins should not be used directly

See original GitHub issue

Version

27.0.6

Steps to reproduce

Expected behavior

test: val => val && Object.prototype.hasOwnProperty.call(val, 'foo'), if (argv.runInBand && Object.prototype.hasOwnProperty.call(argv, 'maxWorkers')) {

Actual behavior

test: val => val && val.hasOwnProperty('foo'), test: val => val && val.hasOwnProperty('foo'),

Additional context

It is preferable to call certain Object.prototype methods through Object on object instances instead of using the builtins directly.

Objects can have properties that shadow the builtins on Object.prototype, potentially causing unintended behavior or denial-of-service security vulnerabilities.

Environment

N/A

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
SimenBcommented, Nov 29, 2021
1reaction
SimenBcommented, Nov 3, 2021

PR very much welcome 🙂

Can add no-prototype-builtins lint rule to find all occurences

Read more comments on GitHub >

github_iconTop Results From Across the Web

JS-0021 · `Object.prototype` builtins should not be used directly
Object.prototype builtins should not be used directly JS-0021. Bug risk ... Do not access Object.prototype method 'hasOwnProperty' from target object.
Read more >
no-prototype-builtins - ESLint - Pluggable JavaScript Linter
This rule prevents calling some Object. prototype methods directly from an object. Additionally, objects can have properties that shadow the builtins on Object ......
Read more >
Object.hasOwnProperty() yields the ESLint 'no-prototype ...
I am getting the following error: Do not access Object.prototype method 'hasOwnProperty' from target object. It is a 'no-prototype-builtins' error.
Read more >
Why do some developers use Object.prototype ... - Nick Ang
Reason 1: objects can be created with no prototype. The first reason is the one cited in ESLint's no-prototype-builtins rule.
Read more >
JavaScript static code analysis: Functions should not be empty
Unique rules to find Bugs, Vulnerabilities, Security Hotspots, and Code ... Objects should not be created to be dropped immediately without being used....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found