False positive: js/incomplete-hostname-regexp treats LinkifyIt.match(text) as a regex call
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 55/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript
- Lĩnh vực
- security
Hướng nghiên cứu
Kiểm tra query js/incomplete-hostname-regexp và các mô hình thư viện của nó, sau đó so sánh tiền lệ Sinon trong PR 19854. Chạy lại cảnh báo CodeQL được liên kết trên test/link-recognition-qualification.test.js; hoàn tất khi các literal LinkifyIt.match(text) không còn bị báo cáo, trong khi các phát hiện regex String.match thông thường vẫn được bật.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description of the false positive
js/incomplete-hostname-regexp treats the argument to LinkifyIt.match(text) as a regular expression. The receiver is a LinkifyIt instance from linkify-it@6.1.0; its argument is document text to scan for links, not a regex pattern. Literal dots in these URLs are therefore correct.
Observed with CodeQL 2.26.4, JavaScript/TypeScript analysis, build-mode: none, and github/codeql-action@cdf488f595d80d6e07e03d4674febd5ab45fa938 (v4.37.9), using the default query suite without custom queries or exclusions.
Diagnostic on the text literal:
This string, which is used as a regular expression here, has an unescaped '.' before 'youtube.com/watc', so it might match more hosts than expected.
The linked use is scanner.match(text).
Code samples or links to source code
Small excerpt retaining the constructor, configuration, literal and call from the reported test:
import { LinkifyIt } from "linkify-it";
const scanner = new LinkifyIt({ fuzzyLink: false, fuzzyEmail: false })
.add("ftp:", null)
.add("mailto:", null)
.add("//", null);
const text =
"😀 *literal* (https://www.youtube.com/watch?v=tax4e4hBBZc), then https://store.steampowered.com/app/457140/.";
const matches = scanner.match(text);
console.log(matches.map((m) => m.raw));
With linkify-it@6.1.0, the API returns matches for the two literal URLs. The package's build/index.d.ts declares match(text: string): Match[] | null; build/index.mjs implements the method by scanning that document text with the library's link recognizers.
Exact reported source at the PR merge revision.
Source at the immutable PR head.
Validation: node --test test/link-recognition-qualification.test.js passes 1/1, including exact URL and offset assertions. The hosted CodeQL analysis reports the finding in the linked full test. The reduced excerpt above has not been separately analyzed with CodeQL; no claim is made that it is the smallest scanner reproducer.
Expected: recognize that this imported library's match method consumes document text, so these literals should not be classified as hostname regular expressions. Ordinary String.match regex findings should remain enabled.
Related precedent: https://github.com/github/codeql/pull/19854 explicitly models Sinon's match calls as non-RegExp. I found no existing linkify-it report in the upstream search.
URL to the alert on GitHub code scanning (optional)
https://github.com/MaksymShostak/steam-community-bbcode/security/code-scanning/2
- Ngôn ngữ chính
- CodeQL
- Star
- 10.1k
- Fork
- 2.1k
- Merge trung bình
- 2 ngày 11 giờ
- Pull request đã merge (30 ngày)
- 129
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của github/codeql
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
-
C#: cs/simplifiable-boolean-expression false positive on Nullable<bool> compared with a literal Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
false-positive
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
False positive Đang mởfalse-positive
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 15/100
Tất cả issue của github/codeql
Issue tương tự
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
TheManticoreProject/Manticore#1383 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
ethereum-optimism/factory#64 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
phoenixframework/phoenix#6847 ·
-
intake mcp-intake needs-ac needs-human-review priority:medium type:bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Ikalus1988/MisakaNet#2019 · 2 bình luận ·
-
Upgrade of litesaml/lightsaml? Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
SocialiteProviders/Providers#1493 ·