Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-security

Package Overview
Dependencies
Maintainers
4
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-security

Security rules for eslint

  • 1.5.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created

What is eslint-plugin-security?

eslint-plugin-security is an ESLint plugin that helps identify potential security issues in your JavaScript code. It provides a set of rules that can be used to catch common security vulnerabilities, such as the use of eval(), potential XSS vulnerabilities, and more.

What are eslint-plugin-security's main functionalities?

Detecting the use of eval()

This rule detects the use of eval() with an expression, which can lead to code injection vulnerabilities. The code sample shows a scenario where user input is passed to eval(), which is flagged by the rule.

/* eslint security/detect-eval-with-expression: 'error' */

const userInput = '2 + 2';
eval(userInput);

Detecting potential XSS vulnerabilities

This rule detects the use of non-literal regular expressions, which can be a source of XSS vulnerabilities. The code sample demonstrates creating a RegExp object with user input, which is flagged by the rule.

/* eslint security/detect-non-literal-regexp: 'error' */

const userInput = '.*';
const regex = new RegExp(userInput);

Detecting potential ReDoS vulnerabilities

This rule detects potentially unsafe regular expressions that could lead to Regular Expression Denial of Service (ReDoS) attacks. The code sample shows an unsafe regex pattern that is flagged by the rule.

/* eslint security/detect-unsafe-regex: 'error' */

const unsafeRegex = /(a+)+$/;
unsafeRegex.test('aaaaaaaaaaaaaaaaaaaaaaaaaaaaa');

Other packages similar to eslint-plugin-security

Keywords

FAQs

Package last updated on 18 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc