{"name":"safe-regex","version":"2.0.2","description":"detect possibly catastrophic, exponential-time regular expressions","main":"index.js","dependencies":{"regexp-tree":"~0.1.1"},"devDependencies":{"tape":"^4.10.1"},"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":"132c9b9d9efbf0ba5a85bfcd1b2bbd365d95b1b1","bugs":{"url":"https://github.com/davisjam/safe-regex/issues"},"_id":"safe-regex@2.0.2","_npmVersion":"6.2.0","_nodeVersion":"10.9.0","_npmUser":{"name":"davisjam","email":"davisjam@vt.edu"},"dist":{"integrity":"sha512-rRALJT0mh4qVFIJ9HvfjKDN77F9vp7kltOpFFI/8e6oKyHFmmxz4aSkY/YVauRDe7U0RrHdw9Lsxdel3E19s0A==","shasum":"3601b28d3aefe4b963d42f6c2cdb241265cbd63c","tarball":"http://registry-npm.ywwl.com/safe-regex/download/safe-regex-2.0.2.tgz","fileCount":8,"unpackedSize":6684,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcdE1VCRA9TVsSAnZWagAAPaMP/2/YYMhPlbkRjDOD0Ixs\nf5A3mmk1k4AXxlXIC9EPu8aInNtrbBycqfIdTT6e/QUAmByT3lJlxMUGHHde\noOJ+nGNwqiNea8O9sOLWgFmr630RmvYCayupGeFKqhpM2Sw75VilIcCHdHbq\nyzWzHgUpjGcdPVuXM0MJ3S/Hk2tG/yHCAKBxmoWKwgMaJf/Ps92/sDaPflwQ\nndx2zzOkk/i/uurwzKnpiaMZfK0u9LbsJbTXvXtNoWaJLhaJNNsoZwcyb0PY\nEhKDw24dWuuCJ2UJLEhRREar+EJnl70FmJpJfQjlV451VNw4PEiJiOFgmwag\nS0dtALEGXkXnoQuIFJkw1rOTIA9YIl3vXWasO9tojruZ9qp7lt915poYIr5y\nNYvtzf3hzhl3/3fkNqU2YhofhL3hOMd7GhtXaGaAo/IQf/X90exTBftTDtvw\n6aX6/OsfPawggM1QxLy/4qLIQIQcxJHhXTJKDctzw9pIKXxjRsmui0B04b8E\njCPWdHRnA+oBgnkGwL3My8ofCwa+eErszudl/Ee6OOUjvy/c+qmQvJpeMaH0\nW5+y2JC5j5uEj8ILsokwdQz4PTlZdrRhvtXKiz5415v5ut+ayEoN7s/fveiF\nBAf5sINDxHOjw3qjidBKXUyIP71VPpL+gJxFU6f3tgMIsJ7MH9NpneaYhhq4\nf3o1\r\n=On78\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICRXQtgq0RjauldAifZrnOCIMUHjstJGnRi7QdlcdRd8AiBORGgpGVyn2+5fz1VlrfqexaUJbcpsCHju0zbsqQ1e0w=="}],"size":3206,"noattachment":false,"key":"/safe-regex/-/safe-regex-2.0.2.tgz"},"maintainers":[{"email":"davisjam@vt.edu","name":"davisjam"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/safe-regex_2.0.2_1551125844844_0.438144546598763"},"_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":1551125845012,"_cnpm_publish_time":1551125845012,"dist-tags":{"latest":"2.1.1"}}