Skip to content

Commit 39302c6

Browse files
committed
Swift: Add support for isDigit and similar.
1 parent 355793f commit 39302c6

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

swift/ql/lib/codeql/swift/regex/RegexTreeView.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,13 +1187,13 @@ private module Impl implements RegexTreeViewSig {
11871187
or
11881188
// TODO: expand to cover more properties
11891189
exists(RegExpNamedCharacterProperty escape | term = escape |
1190-
escape.getName().toLowerCase() = "digit" and
1190+
escape.getName().toLowerCase() = ["digit", "isdigit"] and
11911191
if escape.isInverted() then clazz = "D" else clazz = "d"
11921192
or
1193-
escape.getName().toLowerCase() = "space" and
1193+
escape.getName().toLowerCase() = ["space", "isspace"] and
11941194
if escape.isInverted() then clazz = "S" else clazz = "s"
11951195
or
1196-
escape.getName().toLowerCase() = "word" and
1196+
escape.getName().toLowerCase() = ["word", "isword"] and
11971197
if escape.isInverted() then clazz = "W" else clazz = "w"
11981198
)
11991199
}

swift/ql/test/library-tests/regex/redos_variants.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,9 +535,9 @@ func myRegexpVariantsTests(myUrl: URL) throws {
535535
// GOOD
536536
_ = try Regex(#"X(\P{Digit}|7)+Y"#).firstMatch(in: tainted)
537537

538-
// BAD TODO: we should get this one
538+
// BAD
539539
// attack string: "X" + "7" x lots
540-
_ = try Regex(#"X(\p{IsDigit}|7)*Y"#).firstMatch(in: tainted) // $ MISSING: redos-vulnerable=
540+
_ = try Regex(#"X(\p{IsDigit}|7)*Y"#).firstMatch(in: tainted) // $ redos-vulnerable=
541541

542542
// GOOD
543543
_ = try Regex(#"X(\p{IsDigit}|b)+Y"#).firstMatch(in: tainted)

0 commit comments

Comments
 (0)