[][src]Struct rslint_core::groups::errors::NoPrototypeBuiltins

pub struct NoPrototypeBuiltins {}

Disallow direct use of Object.prototype builtins directly.

ES 5.1 added Object.create which allows creation of object with a custom prototype. This pattern is frequently used for objects used as Maps. However this pattern can lead to errors if something else relies on prototype properties/methods.

Moreover, the methods could be shadowed, this can lead to random bugs and denial of service vulnerabilities. For example, calling hasOwnProperty directly on parsed json could lead to vulnerabilities. Instead, you should use get the method directly from the object using Object.prototype.prop.call(item, args).

Invalid Code Examples

var bar = foo.hasOwnProperty("bar");

var bar = foo.isPrototypeOf(bar);

var bar = foo.propertyIsEnumerable("bar");

Correct Code Examples

var bar = Object.prototype.hasOwnProperty.call(foo, "bar");

var bar = Object.prototype.isPrototypeOf.call(foo, bar);

var bar = Object.propertyIsEnumerable.call(foo, "bar");

Implementations

impl NoPrototypeBuiltins[src]

pub fn new() -> Self[src]

Trait Implementations

impl Clone for NoPrototypeBuiltins[src]

impl CstRule for NoPrototypeBuiltins[src]

impl Debug for NoPrototypeBuiltins[src]

impl Default for NoPrototypeBuiltins[src]

impl<'de> Deserialize<'de> for NoPrototypeBuiltins[src]

impl Rule for NoPrototypeBuiltins[src]

impl Serialize for NoPrototypeBuiltins[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> DynClone for T where
    T: Clone
[src]

impl<T> Erasable for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Serialize for T where
    T: Serialize + ?Sized
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.