How to resolve eslint "Generic Object Injection Sink" error?
You are searching for an ES lint error fix:
Here is the syntax for it
json [`${key}`]
Example:
const obj = { eventName: 'Music event', landingPic: 'landing.jpg', eventPic0: 'pic0.jpg', eventPic1: 'pic1.jpg', eventPic2: 'pic2.jpg', eventPic3: 'pic3.jpg', artist: 'Elie'};// array of keys which need to be readconst arrayOfKey = ['landingPic', 'eventPic0', 'eventPic1', 'eventPic2', 'eventPic3'];// let's read the value by a key in arrayarrayOfKey.forEach( key => { const value = obj[`${key}`]; console.log(value);});
What its trying to say is that using this notation:
- You are able to modify even prototype properties of the object which is considered dangerous
- By being able to modify everything, you are also able to modify the constructor (method/function) so it may be injected and then exploited.
The subject is described analytically here, providing a simple example: