{"name":"safe-regex","version":"2.0.0","description":"detect possibly catastrophic, exponential-time regular expressions","main":"index.js","dependencies":{"regexp-tree":"~0.0.85"},"devDependencies":{"tape":"^3.5.0"},"scripts":{"test":"tape test/*.js"},"testling":{"files":"test/*.js","browsers":["ie/8","ie/9","ie/10","firefox/latest","chrome/latest","opera/latest","safari/latest"]},"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":"cd95cff13de26a3065a97eeb90dba360a95790d8","bugs":{"url":"https://github.com/davisjam/safe-regex/issues"},"_id":"safe-regex@2.0.0","_npmVersion":"5.5.1","_nodeVersion":"8.2.1","_npmUser":{"name":"davisjam","email":"davisjam@vt.edu"},"dist":{"integrity":"sha512-thCAfpaDb/DuCwidgS2h5BGyNx+vcN9F8fPLLhOrDndirBhOAwPkB4V28LMc+/Km1uHOg0APIIXdSg1Ck8BHjw==","shasum":"1c021d0d55ee116bf6caeeb1d7d0a388509f7112","tarball":"http://registry-npm.ywwl.com/safe-regex/download/safe-regex-2.0.0.tgz","fileCount":8,"unpackedSize":6297,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJb01YTCRA9TVsSAnZWagAA6eYP/RGb8XTt77idCZ+SIMT+\nsxoXkclnotDuOvnjje2mMzL5idYn6QQuFe+pTeBtFcaVCUMx3rpKVVd/+z46\nG5Z8qUJc8mrHf9bajUIgwpFVufEVGXmNFGH5fmC7nJQhm18c8ze4SDl1mU+y\nCwdteHQE0PkRtRwF3f8LyzkKg8U6n6c2hGDTZIRYcZa+KHOpXrDwdBbbAdyQ\nF0ZUyPyNRO4kF8t8q/gWs17I56EcvSpdBAnw2je2Ow8HCTh4UD27Y9mF2K6c\nMvSqoUlx5FNf1CO4Wb0kjAYbmh7+5NX2njZa1KUB+jnAa/0jm0oTDg4g5dIh\nFDA02BqRlTZ5uGZv/s3mJQi645Q1L5CVDeOySfvoVG59sNV8hiTOzWisHNxD\nj+Tguiq+88xISuUJJqA9DmVtUvg8LLgJ/o+9Re6C7TziUpR28Cshrbjd9FS7\nV85NZxtLgRHI+Ogm9aZsx8NU8NnElMT+45BFf+7twop/CMhZj6eYS05kZ0Es\n+8EtPulPyX7VBAZb85rPnVX46LNLMCWRqgl6gvkHzDlZjPLqrqA9RCDlhE9x\nxq1qt6DTXRArxWwt6DlPGXNV0Gm3VFr4IqdaRUrchdYj/RbTuE79BO5MTQMa\njInQ1jpb/9z9q+lxim7JX/7ow51htlPc8HusbQsYRVA68poYGmyA4KPyO34i\nXeX0\r\n=3u4b\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGwh6IZvUNysANFojPiq9olbZKv48sjA8YBMxBTa+dfBAiAoBVN00Yar2fME7hI3uviyn68pvdGNl4NfBWZgK46sPQ=="}],"size":3131,"noattachment":false,"key":"/safe-regex/-/safe-regex-2.0.0.tgz"},"maintainers":[{"email":"davisjam@vt.edu","name":"davisjam"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/safe-regex_2.0.0_1540576786474_0.40345973051344486"},"_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":1540576786642,"_cnpm_publish_time":1540576786642,"dist-tags":{"latest":"2.1.1"}}