github / github/codeql

JS: Atomic group polyfill not detected as a ReDOS mitigation

未关闭
#9,062 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
false-positive
主要语言
CodeQL
星标
10.1k
派生
2.1k
平均合并
2 天 15 小时
30 天内合并 PR
141

描述

**Description of the false positive**

You can polyfill atomic groups in JS by using the `/(?=(...))\1//` pattern, but LGTM doesn't seem to understand it and reports a false positive [here](https://lgtm.com/projects/g/compose-regexp/compose-regexp.js/snapshot/e31d432f942019263401085e38558c5661dc7460/files/commonjs/compose-regexp.js?sort=name&dir=ASC&mode=heatmap#xdcee8d483c053100:1).

Here's the culprit:

```JS
var oneEscapeOrCharClassMatcher = /^(?:\\.|\[(?=((?:\\.|.)*?))\1\])$/;
```

There are other similar cases in the project, it is a RegExp composition lib that provides an `atomic(x)` helper that wraps `x` accordingly (and uses such RegExps internally).

Still, to my amusement (and slight consternation), LGTM caught an polynomial ReDOS in my lib... Thanks for the project.

**URL to the alert on the project page on LGTM.com**

https://lgtm.com/projects/g/compose-regexp/compose-regexp.js/snapshot/e31d432f942019263401085e38558c5661dc7460/files/commonjs/compose-regexp.js?sort=name&dir=ASC&mode=heatmap#xdcee8d483c053100:1

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。