github / github/codeql

JS: Atomic group polyfill not detected as a ReDOS mitigation

Đang mở
#9,062 3 bình luận 0 reaction 0 người được giao Xem trên GitHub
false-positive
Ngôn ngữ chính
CodeQL
Star
10.1k
Fork
2.1k
Merge trung bình
2 ngày 15 giờ
Pull request đã merge (30 ngày)
141

Mô tả

**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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.