snyk-labs / eslint-plugin-react-security Goto Github PK
View Code? Open in Web Editor NEWESLint plugin with rules for finding security issues in React projects.
ESLint plugin with rules for finding security issues in React projects.
I've imported this ruleset into my application in my package.json file
"eslint-plugin-react-security": "git+ssh://[email protected]:snyk-labs/eslint-plugin-react-security.git",
I've declared the rule in my .eslintrc.js file like:
plugins: [
'react',
'cypress',
'html',
'no-unsanitized',
'react-security',
'security',
],
rules: {
// # https://github.com/yannickcr/eslint-plugin-react/tree/master/docs/rules
'react/no-danger': 'warn',
'react/no-find-dom-node': 'warn',
'react/jsx-no-script-url': 'warn',
'react/jsx-no-target-blank': 'warn',
'react/jsx-props-no-spreading': 'warn',
// https://github.com/snyk-labs/eslint-plugin-react-security
'no-refs': 'warn',
// https://github.com/mozilla/eslint-plugin-no-unsanitized
'no-unsanitized/method': 'error',
'no-unsanitized/property': 'error',
}
as per the file - https://github.com/snyk-labs/eslint-config-react-security/blob/master/index.js
Which leads me to this error when running eslint
in the application directory.
1:1 error Definition for rule 'no-refs' was not found
Only when I
change 'no-refs': 'warn',
to 'react-security/no-refs': 'warn',
does the error go away and the rule properly resolve.
I think this could easily be solved with some documentation.
The reason my this might get some attention is that someone at Synk blogged about it recently - https://snyk.io/blog/10-react-security-best-practices/
I was using this linter and I noticed that the no-javascript-urls
rule, when linting relative URLs, on situations such as:
<a href="/whatever">Whatever</a>
The following error was thrown:
TypeError [ERR_INVALID_URL]: Invalid URL
I believe it has to do with the URL()
constructor used requiring the base URL when the URL is relative.
Build a rule that catches dangerouslySetInnerHTML usage in JSX and calls to .createElement()
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.