{"name":"safe-regex","version":"2.1.0","description":"detect possibly catastrophic, exponential-time regular expressions","main":"index.js","dependencies":{"regexp-tree":"~0.1.1"},"devDependencies":{"jest":"^24.9.0"},"scripts":{"test":"jest"},"jest":{"moduleFileExtensions":["js"],"testRegex":"test.*\\.spec\\.js$","collectCoverage":true,"coverageReporters":["text-summary","html","lcov"],"collectCoverageFrom":["*.js"],"coverageThreshold":{"global":{"statements":100,"branches":100,"functions":100,"lines":100}}},"repository":{"type":"git","url":"git://github.com/davisjam/safe-regex.git"},"homepage":"https://github.com/davisjam/safe-regex","keywords":["catastrophic","exponential","regex","safe","sandbox"],"author":{"name":"James C.","email":"davisjam@vt.edu","url":"Jamie"},"license":"MIT","gitHead":"329afeae8e8acae78dd86d104ea758533895219f","bugs":{"url":"https://github.com/davisjam/safe-regex/issues"},"_id":"safe-regex@2.1.0","_nodeVersion":"12.10.0","_npmVersion":"6.10.3","dist":{"integrity":"sha512-C2EKpE6DIkQRrVhqMG4NcA3/ekUJBy6YZaGw+77RaO3Odtkm+wb9kNjnM9LHSKwxWr6YYLrGk/MqGg5rOPzElA==","shasum":"3c8c4481278b21d030f6272b8c663de6776130ac","tarball":"http://registry-npm.ywwl.com/safe-regex/download/safe-regex-2.1.0.tgz","fileCount":12,"unpackedSize":14937,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdrgokCRA9TVsSAnZWagAAgIsP/2MJ95jEs1UD5g2zUpm3\nDYxXbYLBcD2LV/DfoElSR+6zdGSaoBQAqq9I+wdzmHZD4GR782hXyjy2dWQl\nUvqcXtmdzbKHYFWEi6psiw5x5N4NzzTwLIPIeEvLcqZpToX18KVKftW3eED4\n0HhaL0ABFvSKWM4NCsi2jkG85x9tFlSiX1oa1iAssDR87cDCFR7QAFxAqaCL\nVnvQCpWxrwz/V0fEHG1hSM97VhvCyz6yGNOXYLmZGz8JyWmSFRLl+WSHQqnh\na3dYGg899HAEwBceb7sM+F09mFym1kUncaH64uUAwuhulhHqT+MAJXkUSHhe\ngPBorf5C1YlSmQuLMZNwRF7/l2bsWq7XGniTr0JIFrJsBAW05LEOcMkujhjz\naVJR2+pP4eaLAI6Yl+z6ULM4PPE6FAxFsUGrvAsDflehvG3PWYLzwcMzsub3\ns2CvmpqJCT6H5wNT4cf7eb56oaOtAsDdDHIRR5XNxMquk+du+dBLtTPPdGC/\nN5eDTW26hjZ8VmjybmIRWgA9AP9wU83GRrQ062xJ68y6ztBHn2CVspQ7j6U3\nIh4uAv3Zq+cAc7Q4k8X/9nW5UM7UgCE3hHwevM6HwZY/LTpICxDFGNc6AM+D\nx9lIetUT62urPk82KDpVnEoXFF5dfiWbykxsIuf6J7n3RzDKRdUOr2GFz9ko\nsbjj\r\n=E4W+\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCVfPP/8gTv756t5ScwsHsLWKS/CmCdDZvT7N7KKfG6rAIhAJnJ2ebZImqe4+JOUEcDko9t55zldgLg/KXwAh8hBWN7"}],"size":5794,"noattachment":false,"key":"/safe-regex/-/safe-regex-2.1.0.tgz"},"maintainers":[{"email":"davisjam@vt.edu","name":"davisjam"}],"_npmUser":{"name":"davisjam","email":"davisjam@vt.edu"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/safe-regex_2.1.0_1571686947761_0.11552026867530052"},"_hasShrinkwrap":false,"readme":"# safe-regex\n\nDetect potentially\n[catastrophic](http://regular-expressions.mobi/catastrophic.html)\n[exponential-time](http://perlgeek.de/blog-en/perl-tips/in-search-of-an-exponetial-regexp.html)\nregular expressions by limiting the\n[star height](https://en.wikipedia.org/wiki/Star_height) to 1.\n\nWARNING: This module has both false positives and false negatives.\nUse [vuln-regex-detector](https://github.com/davisjam/vuln-regex-detector) for improved accuracy.\n\n[![Build Status](https://travis-ci.org/davisjam/safe-regex.svg?branch=master)](https://travis-ci.org/davisjam/safe-regex)\n\n## Example\n\nSuppose you have a script named `safe.js`:\n\n``` js\nvar safe = require('safe-regex');\nvar regex = process.argv.slice(2).join(' ');\nconsole.log(safe(regex));\n```\n\nThis is its behavior:\n\n```\n$ node safe.js '(x+x+)+y'\nfalse\n$ node safe.js '(beep|boop)*'\ntrue\n$ node safe.js '(a+){10}'\nfalse\n$ node safe.js '\\blocation\\s*:[^:\\n]+\\b(Oakland|San Francisco)\\b'\ntrue\n```\n\n## Methods\n\n``` js\nconst safe = require('safe-regex')\n```\n\n### const ok = safe(re, opts={})\n\nReturn a boolean `ok` whether or not the regex `re` is safe and not possibly\ncatastrophic.\n\n`re` can be a `RegExp` object or just a string.\n\nIf the `re` is a string and is an invalid regex, returns `false`.\n\n* `opts.limit` - maximum number of allowed repetitions in the entire regex.\nDefault: `25`.\n\n## Install\n\nWith [npm](https://npmjs.org) do:\n\n```\nnpm install safe-regex\n```\n\n## Resources\n\n### What should I do if my project has a super-linear regex?\n\n1. Confirm that it is *reachable* by untrusted input.\n2. If it is, you can consider whether you can prevent worst-case behavior by trimming the input, revising the regex, or replacing the regex with another algorithm like string functions. For examples, see Table 5 in [this article](http://people.cs.vt.edu/davisjam/downloads/publications/DavisCoghlanServantLee-EcosystemREDOS-ESECFSE18.pdf).\n3. If none of those solutions looks feasible, you might also consider changing regex engines. The [RE2 bindings](https://www.npmjs.com/package/re2) might work, though test carefully to confirm there are no [semantic portability problems](https://medium.com/@davisjam/why-arent-regexes-a-lingua-franca-esecfse19-a36348df3a2?source=friends_link&sk=d21be7f8f723e2080dc993385c6973d1).\n\n### Further reading\n\nThe following documents may be edifying:\n\n- [Research brief on the extent of super-linear regexes in practice](https://medium.com/@davisjam/introduction-987fdc4c7b0?source=friends_link&sk=ceefa4a4ca9617e08ab782c3b1580aea)\n- [Research brief on the variability of super-linear regex behavior across programming languages](https://medium.com/@davisjam/why-arent-regexes-a-lingua-franca-esecfse19-a36348df3a2?source=friends_link&sk=d21be7f8f723e2080dc993385c6973d1)\n- [Comparing regex matching algorithms](https://swtch.com/~rsc/regexp/regexp1.html)\n\n## Project policies\n\n### Versioning\n\nThis project follows [Semantic Versioning 2.0 (semver)](https://semver.org/).\n\nHere are the project-specific meanings of MAJOR, MINOR, and PATCH updates:\n\n- MAJOR: \"Incompatible\" API changes were introduced. There are two types in this module:\n  - Changes that modify the interface\n  - Changes that cause any regexes to be marked as unsafe that were formerly marked as safe\n- MINOR: Functionality was added in a backwards-compatible manner. There are two types in this module:\n  - Refactoring the analyses but not changing their results\n  - Modifying the analyses to reduce false positives, without affecting negatives (false or true)\n- PATCH: I don't anticipate using PATCH for this module\n\n### License\n\n[MIT](https://github.com/davisjam/safe-regex/blob/master/LICENSE)","publish_time":1571686947934,"_cnpm_publish_time":1571686947934,"dist-tags":{"latest":"2.1.1"}}