包详细信息

@rushstack/eslint-plugin-security

microsoft302.2kMIT0.10.0

An ESLint plugin providing rules that identify common security vulnerabilities for browser applications, Node.js tools, and Node.js services

eslint, eslint-config, security

自述文件

@rushstack/eslint-plugin-security

This plugin implements a collection of security rules for ESLint.

Our ambition is to eventually provide a comprehensive set of recommended security rules for:

  • web browser applications
  • Node.js tools
  • Node.js services

If you would like to request or contribute a new security rule, you are encouraged to create a GitHub issue in the Rush Stack monorepo where this project is developed. Thanks!

@rushstack/security/no-unsafe-regexp

Require regular expressions to be constructed from string constants rather than dynamically building strings at runtime.

Rule Details

Regular expressions should be constructed from string constants. Dynamically building strings at runtime may introduce security vulnerabilities, performance concerns, and bugs involving incorrect escaping of special characters.

Examples

The following patterns are considered problems when @rushstack/security/no-unsafe-regexp is enabled:

function parseRestResponse(request: ICatalogRequest,
  items: ICatalogItem[]): ICatalogItem[] {

  // Security vulnerability: A malicious user could invoke the REST service using a
  // "searchPattern" with a complex RegExp that causes a denial of service.
  const regexp: RegExp = new RegExp(request.searchPattern);
  return items.filter(item => regexp.test(item.title));
}
function hasExtension(filePath: string, extension: string): boolean {
  // Escaping mistake: If the "extension" string contains a special character such as ".",
  // it will be interpreted as a regular expression operator. Correctly escaping an arbitrary
  // string is a nontrivial problem due to RegExp implementation differences, as well as contextual
  // issues (since which characters are special changes inside RegExp nesting constructs).
  // In most cases, this problem is better solved without regular expressions.
  const regexp: RegExp = new RegExp(`\.${extension}$`);
  return regexp.test(filePath);
}

The following patterns are NOT considered problems:

function isInteger(s: string): boolean {
  return /[0-9]+/.test(s);
}
function isInteger(s: string): boolean {
  return new RegExp('[0-9]+').test(s);
}

Links

@rushstack/eslint-plugin-security is part of the Rush Stack family of projects.

更新日志

Change Log - @rushstack/eslint-plugin-security

This log was last generated on Tue, 11 Mar 2025 02:12:33 GMT and should not be manually modified.

0.10.0

Tue, 11 Mar 2025 02:12:33 GMT

Minor changes

  • Bump the @typescript-eslint/* packages to add support for TypeScript 5.8.

0.9.0

Sat, 01 Mar 2025 07:23:16 GMT

Minor changes

  • Bump the @typescript-eslint/* dependencies to ~8.24.0 to support newer versions of TypeScript.

0.8.3

Thu, 19 Sep 2024 00:11:08 GMT

Patches

  • Fix ESLint broken links

0.8.2

Sat, 27 Jul 2024 00:10:27 GMT

Patches

  • Include CHANGELOG.md in published releases again

0.8.1

Sat, 17 Feb 2024 06:24:34 GMT

Version update only

0.8.0

Tue, 16 Jan 2024 18:30:10 GMT

Minor changes

  • Add support for TypeScript 5.3 with @typescript-eslint 6.19.x

0.7.1

Tue, 26 Sep 2023 09:30:33 GMT

Version update only

0.7.0

Fri, 15 Sep 2023 00:36:58 GMT

Minor changes

  • Update @types/node from 14 to 18

0.6.0

Mon, 22 May 2023 06:34:32 GMT

Minor changes

  • Upgrade the @typescript-eslint/* dependencies to ~5.59.2

0.5.0

Thu, 29 Sep 2022 07:13:06 GMT

Minor changes

  • Upgraded @typescript-eslint dependencies to 5.30.x to enable support for TypeScript 4.8

0.4.0

Wed, 03 Aug 2022 18:40:35 GMT

Minor changes

  • Upgrade TypeScript dependency to 4.7

0.3.1

Fri, 17 Jun 2022 00:16:18 GMT

Version update only

0.3.0

Sat, 23 Apr 2022 02:13:06 GMT

Minor changes

  • Add support for TypeScript 4.6

0.2.6

Sat, 09 Apr 2022 02:24:26 GMT

Patches

  • Rename the "master" branch to "main".

0.2.5

Tue, 15 Mar 2022 19:15:53 GMT

Patches

  • Fix the path in the package.json "directory" field.

0.2.4

Mon, 06 Dec 2021 16:08:32 GMT

Patches

  • Add support for ESLint v8

0.2.3

Wed, 27 Oct 2021 00:08:15 GMT

Patches

  • Update the package.json repository field to include the directory property.

0.2.2

Thu, 07 Oct 2021 07:13:35 GMT

Patches

  • Update typescript-eslint to add support for TypeScript 4.4.

0.2.1

Thu, 23 Sep 2021 00:10:40 GMT

Patches

  • Upgrade the @types/node dependency to version to version 12.

0.2.0

Mon, 12 Jul 2021 23:08:26 GMT

Minor changes

  • Upgrade @typescript-eslint/* packages to 4.28.0 (GitHub #2389)

0.1.4

Tue, 06 Apr 2021 15:14:22 GMT

Patches

  • Fix unlisted dependency on @typescript-eslint/experimental-utils

0.1.3

Wed, 30 Sep 2020 18:39:17 GMT

Patches

  • Update to build with @rushstack/heft-node-rig

0.1.2

Wed, 30 Sep 2020 06:53:53 GMT

Patches

  • Include missing "License" field.
  • Update README.md

0.1.1

Sat, 19 Sep 2020 04:37:26 GMT

Patches

  • Add missing dependency

0.1.0

Sat, 19 Sep 2020 03:33:06 GMT

Minor changes

  • Initial release