{"_id":"safe-regex2@5.1.2","bin":{"safe-regex2":"bin/safe-regex2.js"},"bugs":{"url":"https://github.com/fastify/safe-regex2/issues"},"dist":{"shasum":"23388c1ad8b2e44bacdf764dab0b8f510e9ffe83","tarball":"http://registry-npm.ywwl.com/safe-regex2/download/safe-regex2-5.1.2.tgz","fileCount":15,"integrity":"sha512-tAtCGFPPP02VroDVzp4daGi6bC7jWG+41D47GKf18FeH/ubvKQHT9VmhAkvtjNOmJwqtApzWeUpEhkyEYULvmw==","signatures":[{"sig":"MEUCIQDQN4btBNNVhAMNHalg717pwiy/z7Db1EVaGC7ZT+8aegIgajshUmTYrIK+B4W8OpaHW+lazOfEYqUSNEmLv6iCxLo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDsHVFJKehSgIdv7nS7BWLHAOdSlrvVxkx4m8bwrjnIYgIhAKBAF2pq2YrGlmvZXy8DaLBgfdsqAaFvUhGer6Ejnott"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/safe-regex2@5.1.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":13454,"size":5479,"noattachment":false,"key":"/safe-regex2/-/safe-regex2-5.1.2.tgz"},"main":"index.js","name":"safe-regex2","type":"commonjs","types":"types/index.d.ts","author":{"url":"https://substack.net","name":"James Halliday","email":"mail@substack.net"},"funding":[{"url":"https://github.com/sponsors/fastify","type":"github"},{"url":"https://opencollective.com/fastify","type":"opencollective"}],"gitHead":"d90e4be755f60897eb4f3d99611fd4e58f3574fa","license":"MIT","scripts":{"lint":"eslint","test":"npm run test:unit && npm run test:typescript","lint:fix":"eslint --fix","test:unit":"c8 --100 node --test","test:typescript":"tstyche"},"version":"5.1.2","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"49f1b77c-9a25-4039-b124-c0ea26f0b3e6"}},"homepage":"https://github.com/fastify/safe-regex2","keywords":["catastrophic","exponential","regex","safe","sandbox"],"repository":{"url":"git+https://github.com/fastify/safe-regex2.git","type":"git"},"_npmVersion":"11.19.0","description":"detect possibly catastrophic, exponential-time regular expressions","directories":{},"maintainers":[{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"matteo.collina","email":"hello@matteocollina.com"}],"_nodeVersion":"24.21.0","contributors":[{"name":"Matteo Collina","email":"hello@matteocollina.com"},{"url":"https://heyhey.to/G","name":"Gürgün Dayıoğlu","email":"hey@gurgun.day"},{"url":"https://james.sumners.info","name":"James Sumners"},{"url":"https://github.com/fdawgs","name":"Frazer Smith","email":"frazer.dev@icloud.com"}],"dependencies":{"ret":"~0.5.0"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^12.0.0","eslint":"^9.17.0","tstyche":"^7.0.0","neostandard":"^0.13.0"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/safe-regex2_5.1.2_1791628365765_0.8779036715308473"},"readme":"# safe-regex2\n\n[![CI](https://github.com/fastify/safe-regex2/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/fastify/safe-regex2/actions/workflows/ci.yml)\n[![NPM version](https://img.shields.io/npm/v/safe-regex2.svg?style=flat)](https://www.npmjs.com/package/safe-regex2)\n[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard)\n\nDetect potentially [catastrophic](https://www.regular-expressions.info/catastrophic.html) [exponential-time](https://perlgeek.de/blog-en/perl-tips/in-search-of-an-exponetial-regexp.html)\nregular expressions by limiting the [star height](https://en.wikipedia.org/wiki/Star_height) to 1.\n\nThis is a fork of https://github.com/substack/safe-regex at 1.1.0.\n\nWARNING: This module has both false positives and false negatives.\nIt is not meant as a full checker, but it detects basic cases.\n\n## Install\n```sh\nnpm i safe-regex2\n```\n\n## Usage via npx\n\nYou can use this module via `npx` without installing it globally:\n\nExample:\n```sh\nnpx safe-regex2 '(x+x+)+y'\n```\n\n## Example\n\n``` js\nconst safe = require('safe-regex2');\nconst regex = process.argv.slice(2).join(' ');\nconsole.log(safe(regex));\n```\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\nReturns a boolean indicating whether the regex `re` is safe\nand not possibly catastrophic.\n\n`re` can be a `RegExp` object or just a string.\n\nIf `re` is a string and is an invalid regex, it returns `false`.\n\n* `opts.limit` - maximum number of allowed repetitions in the entire regex.\nDefault: `25`.\n\n## License\n\nLicensed under [MIT](./LICENSE).\n","publish_time":1791628365860,"_cnpm_publish_time":1791628365860,"dist-tags":{"latest":"5.1.2"}}