Gathering detailed insights and metrics for eslint-plugin-no-unsafe-regex
Gathering detailed insights and metrics for eslint-plugin-no-unsafe-regex
Gathering detailed insights and metrics for eslint-plugin-no-unsafe-regex
Gathering detailed insights and metrics for eslint-plugin-no-unsafe-regex
ESLint rules to disallow unsafe regular expressions.
npm install eslint-plugin-no-unsafe-regex
Typescript
Module System
Node Version
NPM Version
JavaScript (71.52%)
Makefile (28.48%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
13 Stars
9 Commits
1 Forks
2 Watchers
1 Branches
1 Contributors
Updated on Jun 19, 2023
Latest Version
1.0.0
Package Id
eslint-plugin-no-unsafe-regex@1.0.0
Size
3.70 kB
NPM Version
2.14.2
Node Version
0.12.4
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
5
1$ npm install eslint-plugin-no-unsafe-regex
To use the plugin in an .eslintrc
file,
1{ 2 'plugins': [ 3 'no-unsafe-regex' 4 ] 5}
where no-unsafe-regex
is shorthand for eslint-plugin-no-unsafe-regex
. To configure plugin rules,
1{ 2 'plugins': [ 3 'no-unsafe-regex' 4 ], 5 'rules': { 6 'no-unsafe-regex/no-unsafe-regex': 2 7 } 8}
where a plugin rule must be prefixed with the plugin name and a /
; e.g., no-unsafe-regex/<rule>
.
1var plugin = require( 'eslint-plugin-no-unsafe-regex' );
ESLint rules to disallow unsafe regular expressions.
1console.dir( plugin ); 2/* 3 { 4 'rules': { 5 'no-unsafe-regex': <rule> 6 }, 7 'rulesConfig': { 8 'no-unsafe-regex': 2 9 } 10 } 11*/
In order to use the plugin, the plugin must first be installed as a node_modules
dependency.
The plugin only validates regular expression literals and regular expressions created using the RegExp
constructor and literal arguments.
1var re; 2 3// Validated: 4re = /beep/; 5 6// Validated: 7re = new RegExp( 'beep', 'i' ); 8 9// Not validated: 10str = 'beep'; 11re = new RegExp( str, 'i' ); 12 13// Not validated: 14re = new RegExp( new Array( 5 ).join( 'ab' ) );
Validating regular expressions created using non-literal arguments would require reconstructing an execution context, which is beyond the scope of this module. For example, consider
1var getStr = require( './path/to/my/string' ), 2 str = getStr(); 3 4var re = new RegExp( str );
If the return value of getStr
is dynamic, validation is impossible.
1module.exports = { 2 'env': { 3 'node': true 4 }, 5 'plugins': [ 6 // Declare the plugin: 7 'no-unsafe-regex' 8 ], 9 'rules': { 10 'no-path-concat': 2, 11 'no-process-exit': 0, 12 'no-sync': 1, 13 'no-mixed-requires': [ 2, false ], 14 15 // Prefix a plugin rule with `{{plugin_name}}/`: 16 'no-unsafe-regex/no-unsafe-regex': 2 17 } 18};
To run the example code from the top-level application directory,
1$ node ./examples/index.js
Unit tests use the Mocha test framework with Chai assertions. To run the tests, execute the following command in the top-level application directory:
1$ make test
All new feature development should have corresponding unit tests to validate correct functionality.
This repository uses Istanbul as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:
1$ make test-cov
Istanbul creates a ./reports/coverage
directory. To access an HTML version of the report,
1$ make view-cov
Copyright © 2015. Athan Reines.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 0/8 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More