{"name":"safe-regex","version":"2.1.1","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":"9070d9459dac17e281d06e50110fec2cb40cfc67","bugs":{"url":"https://github.com/davisjam/safe-regex/issues"},"_id":"safe-regex@2.1.1","_nodeVersion":"12.10.0","_npmVersion":"6.10.3","dist":{"integrity":"sha512-rx+x8AMzKb5Q5lQ95Zoi6ZbJqwCLkqi3XuJXp5P3rT8OEc6sZCJG5AE5dU3lsgRr/F4Bs31jSlVN+j5KrsGu9A==","shasum":"f7128f00d056e2fe5c11e81a1324dd974aadced2","tarball":"http://registry-npm.ywwl.com/safe-regex/download/safe-regex-2.1.1.tgz","fileCount":12,"unpackedSize":16453,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdrgq+CRA9TVsSAnZWagAATfEQAIJO5L5SSbRfHveBd3zB\nN29CKk0NG/A1JNgbGZQdwIawa9jflOQG/MhoHaUN3os+p9fcJVzJscj2hbR+\nUaIYcvtHAiep3z9J8K2I06amkfmIV6hi3H1XciTcVL+6lvxeYz5uK1Nu8jdj\nP7GSWnn4q8vdtd/adFTJvF3JaZjilMXRiL+FQ7WFP1yjD2xWItPm6AUSEsdj\nD659F89LN60Ru2cjuvQVBBtnrxGxdvXk+EUzdYLMR/3oI1wNYQ61JNJPzF73\nViq8X/9taqbdz36ZfZRFpJy8fnldSoHmcIB2xrxyjGCtrfc7kYp4Rp4bqqSI\nXb1Vvp1FDKVHftqGtau8RnvpwoNi58PuXyLq1DmvqLDN3clcenbKVAdoLUKI\ngrwvCbtGyADJoHUZTT6mu0h0bJYl5/i4Q5rxlQJmB6W9VI028x3kMyTOV6O9\np6vED9/MSVLgLJlvgx6eLE4U3STCNNkmvkntyWuQmLfPIxWk009EWBbrqEd7\nCtH6JCIWh/sUjFfL689RyWNenYk2X/fX1dYlX3D3vuI4BVyHtgomiKy7W/rg\nApORC5/RXeQ4iWXKaw6jQGPPID/ZfLGU5oEBUSwZokyjZTlLN9EwKL0CirdG\nDM8bOw7zxqUatxzNuZlmMXYME20ojFs0XFhPSG7Ltw54rhmmPi6FVpEyA2zU\nr52j\r\n=ZyaJ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDAF6+EX1oow3EkyJBK5OI8Qe4y5txsRIf/8Bnik+QS0gIgF9uDEuPewzM4IeXcEjFezvb/2+0N3AjmmdCaW8Nhqq8="}],"size":6482,"noattachment":false,"key":"/safe-regex/-/safe-regex-2.1.1.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.1_1571687101795_0.5043143354036861"},"_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":1571687101945,"_cnpm_publish_time":1571687101945,"dist-tags":{"latest":"2.1.1"}}