Skip to content
KitploitKITPLOIT
工具漏洞利用博客
Log in
提交
工具漏洞利用博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

订阅源联系隐私© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
braces-security-backport — MIT 许可的 braces 3.0.3,包含经审查的 CVE-2026-93687 深度回溯补丁;仅限固定版本使用 | Kitploit
工具/GitHubGitHub/bernydotjar/braces-security-backport
漏洞分析代码分析实用工具与框架供应链安全
GitHubbernydotjar/braces-security-backport

braces-security-backport

MIT 许可的 braces 3.0.3,包含经审查的 CVE-2026-93687 深度回溯补丁;仅限固定版本使用

查看仓库

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
27天前尚未审核
分享

braces Donate NPM version NPM monthly downloads NPM total downloads Linux Build Status

类 Bash 的花括号展开,使用 JavaScript 实现。相比其他花括号展开库更安全,完整支持 Bash 4.3 花括号规范,且不牺牲速度。

请考虑关注本项目作者 Jon Schlinkert,并考虑为项目加星以表达你的 ❤️ 和支持。

安装

使用 npm 安装:

$ npm install --save braces

v3.0.0 已发布!!

详情请参阅更新日志。

为什么使用花括号?

花括号模式通过增加匹配特定范围和字符序列的能力,使 glob 更加强大。

  • 准确 - 完全支持 Bash 4.3 花括号展开规范(通过所有 Bash 花括号测试)
  • 快速且高性能 - 启动快、运行快,并且随着模式复杂度增加仍能良好扩展。
  • 代码库组织良好 - 当出现边缘情况时,解析器和编译器易于维护和更新。
  • 经过充分测试 - 包含数千条测试断言,并通过所有 Bash、minimatch 和 brace-expansion 单元测试(截至本文撰写之日)。
  • 更安全 - 你不必担心用户定义激进或恶意的花括号模式来破坏你的应用。Braces 会采取措施防止可用于 DDoS 攻击的恶意正则表达式(参见灾难性回溯)。
  • 支持列表 - (又称“集合”)a/{b,c}/d => ['a/b/d', 'a/c/d']
  • 支持序列 - (又称“范围”){01..03} => ['01', '02', '03']
  • 支持步长 - (又称“增量”){2..10..2} => ['2', '4', '6', '8', '10']
  • 支持转义 - 用于防止特殊字符被求值。

用法

主要导出的是一个函数,它接收一个或多个花括号 patterns 和 options。

const braces = require('braces');
// braces(patterns[, options]);

console.log(braces(['{01..05}', '{a..e}']));
//=> ['(0[1-5])', '([a-e])']

console.log(braces(['{01..05}', '{a..e}'], { expand: true }));
//=> ['01', '02', '03', '04', '05', 'a', 'b', 'c', 'd', 'e']

花括号展开与编译

默认情况下,花括号模式会被编译成经过优化的字符串,用于创建正则表达式和进行匹配。

已编译

console.log(braces('a/{x,y,z}/b'));
//=> ['a/(x|y|z)/b']
console.log(braces(['a/{01..20}/b', 'a/{1..5}/b']));
//=> [ 'a/(0[1-9]|1[0-9]|20)/b', 'a/([1-5])/b' ]

展开

通过将 expand 选项设置为 true,或使用 braces.expand()(返回一个数组,类似于你从 Bash、echo {1..5} 或 minimatch 中预期得到的结果)来启用花括号展开:

console.log(braces('a/{x,y,z}/b', { expand: true }));
//=> ['a/x/b', 'a/y/b', 'a/z/b']

console.log(braces.expand('{01..10}'));
//=> ['01','02','03','04','05','06','07','08','09','10']

列表

展开列表(类似 Bash 的“集合”):

console.log(braces('a/{foo,bar,baz}/*.js'));
//=> ['a/(foo|bar|baz)/*.js']

console.log(braces.expand('a/{foo,bar,baz}/*.js'));
//=> ['a/foo/*.js', 'a/bar/*.js', 'a/baz/*.js']

序列

展开字符范围(类似 Bash 的“序列”):

console.log(braces.expand('{1..3}')); // ['1', '2', '3']
console.log(braces.expand('a/{1..3}/b')); // ['a/1/b', 'a/2/b', 'a/3/b']
console.log(braces('{a..c}', { expand: true })); // ['a', 'b', 'c']
console.log(braces('foo/{a..c}', { expand: true })); // ['foo/a', 'foo/b', 'foo/c']

// supports zero-padded ranges
console.log(braces('a/{01..03}/b')); //=> ['a/(0[1-3])/b']
console.log(braces('a/{001..300}/b')); //=> ['a/(0{2}[1-9]|0[1-9][0-9]|[12][0-9]{2}|300)/b']

有关所有可用的范围扩展选项,请参阅 fill-range。

步进范围

步长或增量可与范围一起使用:

console.log(braces.expand('{2..10..2}'));
//=> ['2', '4', '6', '8', '10']

console.log(braces('{2..10..2}'));
//=> ['(2|4|6|8|10)']

当使用 .optimize 方法,或将 options.optimize 设置为 true 时,序列会被传递给 to-regex-range 进行展开。

嵌套

花括号模式可以嵌套。每个展开字符串的结果不会排序,并且保留从左到右的顺序。

“展开”花括号

console.log(braces.expand('a{b,c,/{x,y}}/e'));
//=> ['ab/e', 'ac/e', 'a/x/e', 'a/y/e']

console.log(braces.expand('a/{x,{1..5},y}/c'));
//=> ['a/x/c', 'a/1/c', 'a/2/c', 'a/3/c', 'a/4/c', 'a/5/c', 'a/y/c']

“优化”花括号

console.log(braces('a{b,c,/{x,y}}/e'));
//=> ['a(b|c|/(x|y))/e']

console.log(braces('a/{x,{1..5},y}/c'));
//=> ['a/(x|([1-5])|y)/c']

转义

转义花括号

如果_左花括号或右花括号被转义_,则花括号模式不会被展开或求值:

console.log(braces.expand('a\\{d,c,b}e'));
//=> ['a{d,c,b}e']

console.log(braces.expand('a{d,c,b\\}e'));
//=> ['a{d,c,b}e']

转义逗号

花括号内的逗号也可以被转义:

console.log(braces.expand('a{b\\,c}d'));
//=> ['a{b,c}d']

console.log(braces.expand('a{d\\,c,b}e'));
//=> ['ad,ce', 'abe']

单个项

按照 bash 的惯例,当花括号模式只包含单个字符时,它也不会被展开:

console.log(braces.expand('a{b}c'));
//=> ['a{b}c']

选项

options.maxLength

类型:Number

默认值:10,000

描述:限制输入字符串的长度。当输入字符串是生成的,或你的应用允许用户传入字符串等场景下很有用。

console.log(braces('a/{b,c}/d', { maxLength: 3 })); //=> throws an error

options.expand

类型:Boolean

默认值:undefined

描述:生成一个“展开”的花括号模式(或者你也可以使用 braces.expand() 方法,其作用相同)。

console.log(braces('a/{b,c}/d', { expand: true }));
//=> [ 'a/b/d', 'a/c/d' ]

options.nodupes

类型:Boolean

默认值:undefined

描述:从返回的数组中移除重复项。

options.rangeLimit

类型:Number

默认值:1000

描述:为防止用户传入恶意模式,当使用 braces.expand() 或 options.expand 为 true 且生成的 range 将超过 rangeLimit 时,会抛出错误。

你可以自定义 options.rangeLimit 或将其设置为 Inifinity 以完全禁用此限制。

示例

// pattern exceeds the "rangeLimit", so it's optimized automatically
console.log(braces.expand('{1..1000}'));
//=> ['([1-9]|[1-9][0-9]{1,2}|1000)']

// pattern does not exceed "rangeLimit", so it's NOT optimized
console.log(braces.expand('{1..100}'));
//=> ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '60', '61', '62', '63', '64', '65', '66', '67', '68', '69', '70', '71', '72', '73', '74', '75', '76', '77', '78', '79', '80', '81', '82', '83', '84', '85', '86', '87', '88', '89', '90', '91', '92', '93', '94', '95', '96', '97', '98', '99', '100']

options.transform

类型:Function

默认值:undefined

描述:自定义范围扩展。

示例:转换非数值

const alpha = braces.expand('x/{a..e}/y', {
  transform(value, index) {
    // When non-numeric values are passed, "value" is a character code.
    return 'foo/' + String.fromCharCode(value) + '-' + index;
  },
});
console.log(alpha);
//=> [ 'x/foo/a-0/y', 'x/foo/b-1/y', 'x/foo/c-2/y', 'x/foo/d-3/y', 'x/foo/e-4/y' ]

示例:转换数值

const numeric = braces.expand('{1..5}', {
  transform(value) {
    // when numeric values are passed, "value" is a number
    return 'foo/' + value * 2;
  },
});
console.log(numeric);
//=> [ 'foo/2', 'foo/4', 'foo/6', 'foo/8', 'foo/10' ]

options.quantifiers

类型:Boolean

默认值:undefined

描述:在正则表达式中,量词可用于指定某个标记可以重复的次数。例如,a{1,3} 将匹配字母 a 一到三次。

不幸的是,正则量词恰好与 Bash 列表 共享相同的语法。

quantifiers 选项告诉 braces 在给定模式中检测何时定义了 正则量词,并且不要尝试将它们作为列表展开。

示例

const braces = require('braces');
console.log(braces('a/b{1,3}/{x,y,z}'));
//=> [ 'a/b(1|3)/(x|y|z)' ]
console.log(braces('a/b{1,3}/{x,y,z}', { quantifiers: true }));
//=> [ 'a/b{1,3}/(x|y|z)' ]
console.log(braces('a/b{1,3}/{x,y,z}', { quantifiers: true, expand: true }));
//=> [ 'a/b{1,3}/x', 'a/b{1,3}/y', 'a/b{1,3}/z' ]

options.keepEscaping

类型:Boolean

默认值:undefined

描述:不要从结果中去除用于转义的反斜杠。

什么是“花括号展开”?

花括号展开是一种参数展开,由 Unix shell 推广开来,用于生成字符串列表,以及与通配符(globs)配合使用时进行类似正则的匹配。

除了“展开”,花括号也用于匹配。换句话说:

  • 花括号展开用于生成新的列表
  • 花括号匹配用于过滤现有列表
下载工具