Merge pull request #11248 from erik-krogh/js-redosMod

JS: use the shared regex pack
This commit is contained in:
Erik Krogh Kristensen
2022-12-05 14:48:37 +01:00
committed by GitHub
26 changed files with 161 additions and 2695 deletions

View File

@@ -12,8 +12,9 @@
* external/cwe/cwe-020
*/
import semmle.javascript.security.OverlyLargeRangeQuery
private import semmle.javascript.security.regexp.RegExpTreeView::RegExpTreeView as TreeView
import codeql.regex.OverlyLargeRangeQuery::Make<TreeView>
from RegExpCharacterRange range, string reason
from TreeView::RegExpCharacterRange range, string reason
where problem(range, reason)
select range, "Suspicious character range that " + reason + "."

View File

@@ -16,7 +16,8 @@
* external/cwe/cwe-186
*/
import semmle.javascript.security.BadTagFilterQuery
private import semmle.javascript.security.regexp.RegExpTreeView::RegExpTreeView as TreeView
import codeql.regex.nfa.BadTagFilterQuery::Make<TreeView>
from HtmlMatchingRegExp regexp, string msg
where msg = min(string m | isBadRegexpFilter(regexp, m) | m order by m.length(), m) // there might be multiple, we arbitrarily pick the shortest one

View File

@@ -20,7 +20,8 @@ string toOtherCase(string s) {
if s.regexpMatch(".*[a-z].*") then result = s.toUpperCase() else result = s.toLowerCase()
}
import semmle.javascript.security.regexp.NfaUtils as NfaUtils
private import semmle.javascript.security.regexp.RegExpTreeView::RegExpTreeView as TreeView
import codeql.regex.nfa.NfaUtils::Make<TreeView> as NfaUtils
/** Holds if `s` is a relevant regexp term were we want to compute a string that matches the term (for `getCaseSensitiveBypassExample`). */
predicate isCand(NfaUtils::State s) {
@@ -92,7 +93,7 @@ string getAnEndpointExample(Routing::RouteSetup endpoint) {
)
}
import semmle.javascript.security.regexp.RegexpMatching as RegexpMatching
import codeql.regex.nfa.RegexpMatching::Make<TreeView> as RegexpMatching
NfaUtils::RegExpRoot getARoot(DataFlow::RegExpCreationNode creator) {
result.getRootTerm() = creator.getRoot()