3.0.1 • Published 12 months ago

eslint-plugin-security v3.0.1

Weekly downloads
245,997
License
Apache-2.0
Repository
github
Last release
12 months ago

eslint-plugin-security

NPM version

ESLint rules for Node Security

This project will help identify potential security hotspots, but finds a lot of false positives which need triage by a human.

Installation

npm install --save-dev eslint-plugin-security

or

yarn add --dev eslint-plugin-security

Usage

Flat config (requires eslint >= v8.23.0)

Add the following to your eslint.config.js file:

const pluginSecurity = require('eslint-plugin-security');

module.exports = [pluginSecurity.configs.recommended];

eslintrc config (deprecated)

Add the following to your .eslintrc file:

module.exports = {
  extends: ['plugin:security/recommended-legacy'],
};

Developer guide

  • Use GitHub pull requests.
  • Conventions:
  • We use our custom ESLint setup.
  • Please implement a test for each new rule and use this command to be sure the new code respects the style guide and the tests keep passing:
npm run-script cont-int

Tests

npm test

Rules

⚠️ Configurations set to warn in.\ ✅ Set in the recommended configuration.

Name                                 Description⚠️
detect-bidi-charactersDetects trojan source attacks that employ unicode bidi attacks to inject malicious code.
detect-buffer-noassertDetects calls to "buffer" with "noAssert" flag set.
detect-child-processDetects instances of "child_process" & non-literal "exec()" calls.
detect-disable-mustache-escapeDetects "object.escapeMarkup = false", which can be used with some template engines to disable escaping of HTML entities.
detect-eval-with-expressionDetects "eval(variable)" which can allow an attacker to run arbitrary code inside your process.
detect-new-bufferDetects instances of new Buffer(argument) where argument is any non-literal value.
detect-no-csrf-before-method-overrideDetects Express "csrf" middleware setup before "method-override" middleware.
detect-non-literal-fs-filenameDetects variable in filename argument of "fs" calls, which might allow an attacker to access anything on your system.
detect-non-literal-regexpDetects "RegExp(variable)", which might allow an attacker to DOS your server with a long-running regular expression.
detect-non-literal-requireDetects "require(variable)", which might allow an attacker to load and run arbitrary code, or access arbitrary files on disk.
detect-object-injectionDetects "variablekey" as a left- or right-hand assignment operand.
detect-possible-timing-attacksDetects insecure comparisons (==, !=, !== and ===), which check input sequentially.
detect-pseudoRandomBytesDetects if "pseudoRandomBytes()" is in use, which might not give you the randomness you need and expect.
detect-unsafe-regexDetects potentially unsafe regular expressions, which may take a very long time to run, blocking the event loop.

TypeScript support

Type definitions for this package are managed by DefinitelyTyped. Use @types/eslint-plugin-security for type checking.

npm install --save-dev @types/eslint-plugin-security

# OR

yarn add --dev @types/eslint-plugin-security
pocketrocket-commonandrei-cfn@wildberries/boilerplate-eslint-config@defencedigital/r2d2-lint-config@built/eslint-config@oscarltz/eslint@selfagencyllc/dev-toolseslint-config-seruseslint-config-happyeslint-config-neaf@paxsoftware/eslint-config@phanect/eslint-config-phanective@tomcarter17/eslint-config-typescript-react@miszo/eslint-configbreki-styleguideseslint-config-gorrioneslint-config-gekutechmichaelkohler-eslint-config-base@michaelkohler/eslint-config-base@infinitebrahmanuniverse/nolb-eslint-plugin-s@etchteam/eslinteslint-config-equips-tseslint-config-watchfuleslint-config-tyler-zeyeslint-tyler-zey@everything-registry/sub-chunk-1614@aaos/config-eslintiamphoto-ms-lintermoar-js-devildella-test-commonseslint-config-miszodh-test-common-componentsweb-ui-depswheelhouse-linterstorage-packstorybook-delavalvrai-client-sdk@djthoms/eslint-config@code-quality/eslint-config-node@compositive/eslint-config@component-hook/eslint-plugin@colussi/eslint-config@curve-technology/web-ds@cortl/eslint-config@diplodoc/eslint-config@diplodoc/lint@darksheep/eslint@developer-kit/eslint-config@dethdkn/eslint-config@defencedigital/react-lint-config@dragongate/eslint-config@bou-company/eslint-config@paxsoftware/core-boilerplate@posdim/eslint-config@preply-ds/eslint-config@runly/eslint-configeslint-config-rel1cxitsa-react-serverjssajsh-lintkeonkaonjs@acmuta-research/eslint-config@rithum-ui/eslint-config@avenue-ui/eslint-configbolt-visualiser@anylint/eslint-config@anonrig/eslint-config@annangela/eslint-config@ansearch/config@anolilab/eslint-config@atlascommunity/eslint-config@atlassian-partner-engineering/eslint-config@atls/config-eslint@askbills/eslint-config-node@asyncapi/glee@authentiqagency/eslint-config@arianrhodsandlot/eslint-config@automattic/eslint-plugin-wpvip@adobe/aio-cli-plugin-api-mesh@adobe-apimesh/mesh-builder@alexandragr-ssr-micro/eslint-react@aligent/eslint-config@aligent/eslint-config-aligent@aligent/eslint-preset@aliheym/eslint-config@babbel/eslint-config@bigbinary/neeto-api-keys-frontend@bruhabruh/eslint-config@bravo68web/eslint-config@celsodias12/eslint-config-javascript@chiubaka/eslint-config@cinnabar-forge/eslint-plugin@ckt1031/eslint-config@chadly/eslint-config@ackee/styleguide-backend-config@actinc/eslint-config@actinc/eslint-plugin@adhamu/zero@abeai/eslint-config
3.0.1

12 months ago

3.0.0

1 year ago

2.1.1

1 year ago

2.1.0

1 year ago

2.0.0

2 years ago

1.7.1

2 years ago

1.7.0

2 years ago

1.6.0

2 years ago

1.5.0

3 years ago

1.4.0

8 years ago

1.3.0

8 years ago

1.2.0

9 years ago

1.1.0

9 years ago

1.0.0

10 years ago