An ESLint plugin that detects potential XSS vulnerabilities in React (dangerouslySetInnerHTML) and Vue (v-html) applications. Current stable version is 2.1.0, with irregular releases. It enforces the use of a sanitization function (like DOMPurify) on all dynamic HTML content. Compared to generic XSS scanners, RisXSS integrates directly into the linting pipeline, providing instant feedback during development. It supports both React and Vue, and allows configuration of trusted sanitization libraries.
npm install eslint-plugin-risxssVerified import paths — ran on the pinned version, not inferred.
Demonstrates installing the plugin, configuring the React XSS rule, and a component that triggers the lint error with the fix using DOMPurify.sanitize.
Replace any usage of `trustedCalls` option with `trustedLibraries` array of function names.
Add `trustedLibraries: ['yourSanitizer']` to the rule options.
Define any dynamic HTML generation in a function that uses a trusted sanitizer and is called with known arguments.
Always wrap the HTML in a call to a trusted sanitizer like `DOMPurify.sanitize`.
Consider using additional linting rules or manual reviews for other XSS vectors.
Run `yarn add eslint-plugin-risxss --dev` and add `'risxss'` to the `plugins` array in your ESLint config.
Install the plugin: `npm install eslint-plugin-risxss --save-dev` or `yarn add eslint-plugin-risxss --dev`.
Wrap the value in `DOMPurify.sanitize()` or a custom function listed in `trustedLibraries`.