Closed
Description
Query PR
Language
Javascript
CVE(s) ID list
CVE-2018-3737
uses global flag for parsing ssh public key.
Other incorrect regular expressions.
CWE
CWE-20: Improper Input Validation
CWE-185: Incorrect Regular Expression
Report
Overview
This pull request adds a new CodeQL query designed to detect issues related to the use of the global flag (g
) in regular expressions within JavaScript and TypeScript codebases. This query focuses on identifying instances where the global flag might lead to inconsistent or erroneous behavior, particularly when used in conjunction with the test
method of RegExp objects. The goal is to help developers identify and rectify potential bugs in their code related to global regular expressions.
Changes Introduced
- New Query Added:
RegexValidation.ql
- Identifies potentially problematic uses of the global flag in regular expressions, especially when used intest
method calls. - Code Examples: Provided in the
/CWE-020
directory, showcasing both problematic (bad) and corrected (good) usage scenarios. - Documentation: Comprehensive documentation detailing the query's purpose, how it works, and the specific issue it addresses, including examples and best practices.
const forbidden = /['|]/g;
forbidden.test("'")
Are you planning to discuss this vulnerability submission publicly? (Blog Post, social networks, etc).
- Yes
- No
Blog post link
No response