Gathering detailed insights and metrics for safe-regex
Gathering detailed insights and metrics for safe-regex
Gathering detailed insights and metrics for safe-regex
Gathering detailed insights and metrics for safe-regex
safe-regex-test
Give a regex, get a robust predicate function that tests it against a string.
safe-regex2
detect possibly catastrophic, exponential-time regular expressions
@types/safe-regex
TypeScript definitions for safe-regex
@types/safe-regex-test
TypeScript definitions for safe-regex-test
Detect possibly catastrophic, exponential-time regular expressions
npm install safe-regex
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
NOASSERTION License
184 Stars
85 Commits
10 Forks
4 Watchers
15 Branches
2 Contributors
Updated on May 30, 2025
Latest Version
2.1.1
Package Id
safe-regex@2.1.1
Size
6.33 kB
NPM Version
6.10.3
Node Version
12.10.0
Published on
Oct 21, 2019
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
1
Detect potentially catastrophic exponential-time regular expressions by limiting the star height to 1.
WARNING: This module has both false positives and false negatives. Use vuln-regex-detector for improved accuracy.
Suppose you have a script named safe.js
:
1var safe = require('safe-regex'); 2var regex = process.argv.slice(2).join(' '); 3console.log(safe(regex));
This is its behavior:
$ node safe.js '(x+x+)+y'
false
$ node safe.js '(beep|boop)*'
true
$ node safe.js '(a+){10}'
false
$ node safe.js '\blocation\s*:[^:\n]+\b(Oakland|San Francisco)\b'
true
1const safe = require('safe-regex')
Return a boolean ok
whether or not the regex re
is safe and not possibly
catastrophic.
re
can be a RegExp
object or just a string.
If the re
is a string and is an invalid regex, returns false
.
opts.limit
- maximum number of allowed repetitions in the entire regex.
Default: 25
.With npm do:
npm install safe-regex
The following documents may be edifying:
This project follows Semantic Versioning 2.0 (semver).
Here are the project-specific meanings of MAJOR, MINOR, and PATCH updates:
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
Found 1/6 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
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-14
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