Skip to content

Detects potential catastrophic backtracking regular expressions.

License

Notifications You must be signed in to change notification settings

b0uh/safe-regex-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm version CircleCI

⚠️ Warning: This module is still experimental. It should not be used in production.

safe-regex-parser

Parse javascript files to find unsafe regex (a.k.a. potentially catastrophic exponential-time regular expressions)

Getting Started

srp path/to/my/awsome/project/*.js

Prerequisites

  • nodejs
  • npm

Installing

npm i

Options

-n, --include-node-modules    include `node_modules` directory (default: false)
-o, --output-format <format>  output format (text|json) (default: text)
-a, --all                     include safe and unsafe regex in the output, by default only the unsafe regex are included
-v, --version                 output version information
-h, --help                    output usage information

API

const { srp } = require('safe-regex-parser');

const config = {
    pathes: ['./path/to/my/awsome/project/*.js'],
};

const result = srp(config);

TODO

  • Tests
  • Handle multiple regex analyzer
  • Support multiple parser
  • Declare options in a file (including for acorn options)

License

See the LICENSE file for license rights and limitations (MIT).

About

Detects potential catastrophic backtracking regular expressions.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published