mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
other changes based on Esbens review
This commit is contained in:
@@ -75,13 +75,13 @@ predicate overlapsWithCharEscape(RegExpCharacterRange range, RegExpCharacterClas
|
|||||||
range.isRange(low, high)
|
range.isRange(low, high)
|
||||||
|
|
|
|
||||||
escape.getValue() = "w" and
|
escape.getValue() = "w" and
|
||||||
inRange(low, high).regexpMatch("\\w")
|
getInRange(low, high).regexpMatch("\\w")
|
||||||
or
|
or
|
||||||
escape.getValue() = "d" and
|
escape.getValue() = "d" and
|
||||||
inRange(low, high).regexpMatch("\\d")
|
getInRange(low, high).regexpMatch("\\d")
|
||||||
or
|
or
|
||||||
escape.getValue() = "s" and
|
escape.getValue() = "s" and
|
||||||
inRange(low, high).regexpMatch("\\s")
|
getInRange(low, high).regexpMatch("\\s")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ class OverlyWideRange extends RegExpCharacterRange {
|
|||||||
// any non-alpha numeric as part of the range
|
// any non-alpha numeric as part of the range
|
||||||
not isAlphanumeric([low, high].toUnicode())
|
not isAlphanumeric([low, high].toUnicode())
|
||||||
) and
|
) and
|
||||||
// some cases I want to exclude from being flagged
|
// allowlist for known ranges
|
||||||
not this = allowedWideRanges()
|
not this = allowedWideRanges()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,16 +125,16 @@ RegExpCharacterRange allowedWideRanges() {
|
|||||||
// the same with " " and "!". " " is the first printable character, and "!" is the first non-white-space printable character.
|
// the same with " " and "!". " " is the first printable character, and "!" is the first non-white-space printable character.
|
||||||
result.isRange([" ", "!"], _)
|
result.isRange([" ", "!"], _)
|
||||||
or
|
or
|
||||||
// I've seen this often enough, looks OK.
|
// the `[@-_]` range is intentional
|
||||||
result.isRange("@", "_")
|
result.isRange("@", "_")
|
||||||
or
|
or
|
||||||
// starting from the zero byte is a good indication that it's purposely matching a large range.
|
// starting from the zero byte is a good indication that it's purposely matching a large range.
|
||||||
result.isRange(0.toUnicode(), _)
|
result.isRange(0.toUnicode(), _)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Gets all chars between (and including) `low` and `high`. */
|
/** Gets a char between (and including) `low` and `high`. */
|
||||||
bindingset[low, high]
|
bindingset[low, high]
|
||||||
private string inRange(string low, string high) {
|
private string getInRange(string low, string high) {
|
||||||
result = [toCodePoint(low) .. toCodePoint(high)].toUnicode()
|
result = [toCodePoint(low) .. toCodePoint(high)].toUnicode()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,7 +239,8 @@ module RangePrinter {
|
|||||||
isAlphanumeric(high)
|
isAlphanumeric(high)
|
||||||
then result = low + "-" + high
|
then result = low + "-" + high
|
||||||
else
|
else
|
||||||
result = strictconcat(string char | char = inRange(low, high) | escape(char) order by char)
|
result =
|
||||||
|
strictconcat(string char | char = getInRange(low, high) | escape(char) order by char)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,13 +75,13 @@ predicate overlapsWithCharEscape(RegExpCharacterRange range, RegExpCharacterClas
|
|||||||
range.isRange(low, high)
|
range.isRange(low, high)
|
||||||
|
|
|
|
||||||
escape.getValue() = "w" and
|
escape.getValue() = "w" and
|
||||||
inRange(low, high).regexpMatch("\\w")
|
getInRange(low, high).regexpMatch("\\w")
|
||||||
or
|
or
|
||||||
escape.getValue() = "d" and
|
escape.getValue() = "d" and
|
||||||
inRange(low, high).regexpMatch("\\d")
|
getInRange(low, high).regexpMatch("\\d")
|
||||||
or
|
or
|
||||||
escape.getValue() = "s" and
|
escape.getValue() = "s" and
|
||||||
inRange(low, high).regexpMatch("\\s")
|
getInRange(low, high).regexpMatch("\\s")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ class OverlyWideRange extends RegExpCharacterRange {
|
|||||||
// any non-alpha numeric as part of the range
|
// any non-alpha numeric as part of the range
|
||||||
not isAlphanumeric([low, high].toUnicode())
|
not isAlphanumeric([low, high].toUnicode())
|
||||||
) and
|
) and
|
||||||
// some cases I want to exclude from being flagged
|
// allowlist for known ranges
|
||||||
not this = allowedWideRanges()
|
not this = allowedWideRanges()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,16 +125,16 @@ RegExpCharacterRange allowedWideRanges() {
|
|||||||
// the same with " " and "!". " " is the first printable character, and "!" is the first non-white-space printable character.
|
// the same with " " and "!". " " is the first printable character, and "!" is the first non-white-space printable character.
|
||||||
result.isRange([" ", "!"], _)
|
result.isRange([" ", "!"], _)
|
||||||
or
|
or
|
||||||
// I've seen this often enough, looks OK.
|
// the `[@-_]` range is intentional
|
||||||
result.isRange("@", "_")
|
result.isRange("@", "_")
|
||||||
or
|
or
|
||||||
// starting from the zero byte is a good indication that it's purposely matching a large range.
|
// starting from the zero byte is a good indication that it's purposely matching a large range.
|
||||||
result.isRange(0.toUnicode(), _)
|
result.isRange(0.toUnicode(), _)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Gets all chars between (and including) `low` and `high`. */
|
/** Gets a char between (and including) `low` and `high`. */
|
||||||
bindingset[low, high]
|
bindingset[low, high]
|
||||||
private string inRange(string low, string high) {
|
private string getInRange(string low, string high) {
|
||||||
result = [toCodePoint(low) .. toCodePoint(high)].toUnicode()
|
result = [toCodePoint(low) .. toCodePoint(high)].toUnicode()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,7 +239,8 @@ module RangePrinter {
|
|||||||
isAlphanumeric(high)
|
isAlphanumeric(high)
|
||||||
then result = low + "-" + high
|
then result = low + "-" + high
|
||||||
else
|
else
|
||||||
result = strictconcat(string char | char = inRange(low, high) | escape(char) order by char)
|
result =
|
||||||
|
strictconcat(string char | char = getInRange(low, high) | escape(char) order by char)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,13 +75,13 @@ predicate overlapsWithCharEscape(RegExpCharacterRange range, RegExpCharacterClas
|
|||||||
range.isRange(low, high)
|
range.isRange(low, high)
|
||||||
|
|
|
|
||||||
escape.getValue() = "w" and
|
escape.getValue() = "w" and
|
||||||
inRange(low, high).regexpMatch("\\w")
|
getInRange(low, high).regexpMatch("\\w")
|
||||||
or
|
or
|
||||||
escape.getValue() = "d" and
|
escape.getValue() = "d" and
|
||||||
inRange(low, high).regexpMatch("\\d")
|
getInRange(low, high).regexpMatch("\\d")
|
||||||
or
|
or
|
||||||
escape.getValue() = "s" and
|
escape.getValue() = "s" and
|
||||||
inRange(low, high).regexpMatch("\\s")
|
getInRange(low, high).regexpMatch("\\s")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ class OverlyWideRange extends RegExpCharacterRange {
|
|||||||
// any non-alpha numeric as part of the range
|
// any non-alpha numeric as part of the range
|
||||||
not isAlphanumeric([low, high].toUnicode())
|
not isAlphanumeric([low, high].toUnicode())
|
||||||
) and
|
) and
|
||||||
// some cases I want to exclude from being flagged
|
// allowlist for known ranges
|
||||||
not this = allowedWideRanges()
|
not this = allowedWideRanges()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,16 +125,16 @@ RegExpCharacterRange allowedWideRanges() {
|
|||||||
// the same with " " and "!". " " is the first printable character, and "!" is the first non-white-space printable character.
|
// the same with " " and "!". " " is the first printable character, and "!" is the first non-white-space printable character.
|
||||||
result.isRange([" ", "!"], _)
|
result.isRange([" ", "!"], _)
|
||||||
or
|
or
|
||||||
// I've seen this often enough, looks OK.
|
// the `[@-_]` range is intentional
|
||||||
result.isRange("@", "_")
|
result.isRange("@", "_")
|
||||||
or
|
or
|
||||||
// starting from the zero byte is a good indication that it's purposely matching a large range.
|
// starting from the zero byte is a good indication that it's purposely matching a large range.
|
||||||
result.isRange(0.toUnicode(), _)
|
result.isRange(0.toUnicode(), _)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Gets all chars between (and including) `low` and `high`. */
|
/** Gets a char between (and including) `low` and `high`. */
|
||||||
bindingset[low, high]
|
bindingset[low, high]
|
||||||
private string inRange(string low, string high) {
|
private string getInRange(string low, string high) {
|
||||||
result = [toCodePoint(low) .. toCodePoint(high)].toUnicode()
|
result = [toCodePoint(low) .. toCodePoint(high)].toUnicode()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,7 +239,8 @@ module RangePrinter {
|
|||||||
isAlphanumeric(high)
|
isAlphanumeric(high)
|
||||||
then result = low + "-" + high
|
then result = low + "-" + high
|
||||||
else
|
else
|
||||||
result = strictconcat(string char | char = inRange(low, high) | escape(char) order by char)
|
result =
|
||||||
|
strictconcat(string char | char = getInRange(low, high) | escape(char) order by char)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,13 +75,13 @@ predicate overlapsWithCharEscape(RegExpCharacterRange range, RegExpCharacterClas
|
|||||||
range.isRange(low, high)
|
range.isRange(low, high)
|
||||||
|
|
|
|
||||||
escape.getValue() = "w" and
|
escape.getValue() = "w" and
|
||||||
inRange(low, high).regexpMatch("\\w")
|
getInRange(low, high).regexpMatch("\\w")
|
||||||
or
|
or
|
||||||
escape.getValue() = "d" and
|
escape.getValue() = "d" and
|
||||||
inRange(low, high).regexpMatch("\\d")
|
getInRange(low, high).regexpMatch("\\d")
|
||||||
or
|
or
|
||||||
escape.getValue() = "s" and
|
escape.getValue() = "s" and
|
||||||
inRange(low, high).regexpMatch("\\s")
|
getInRange(low, high).regexpMatch("\\s")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ class OverlyWideRange extends RegExpCharacterRange {
|
|||||||
// any non-alpha numeric as part of the range
|
// any non-alpha numeric as part of the range
|
||||||
not isAlphanumeric([low, high].toUnicode())
|
not isAlphanumeric([low, high].toUnicode())
|
||||||
) and
|
) and
|
||||||
// some cases I want to exclude from being flagged
|
// allowlist for known ranges
|
||||||
not this = allowedWideRanges()
|
not this = allowedWideRanges()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,16 +125,16 @@ RegExpCharacterRange allowedWideRanges() {
|
|||||||
// the same with " " and "!". " " is the first printable character, and "!" is the first non-white-space printable character.
|
// the same with " " and "!". " " is the first printable character, and "!" is the first non-white-space printable character.
|
||||||
result.isRange([" ", "!"], _)
|
result.isRange([" ", "!"], _)
|
||||||
or
|
or
|
||||||
// I've seen this often enough, looks OK.
|
// the `[@-_]` range is intentional
|
||||||
result.isRange("@", "_")
|
result.isRange("@", "_")
|
||||||
or
|
or
|
||||||
// starting from the zero byte is a good indication that it's purposely matching a large range.
|
// starting from the zero byte is a good indication that it's purposely matching a large range.
|
||||||
result.isRange(0.toUnicode(), _)
|
result.isRange(0.toUnicode(), _)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Gets all chars between (and including) `low` and `high`. */
|
/** Gets a char between (and including) `low` and `high`. */
|
||||||
bindingset[low, high]
|
bindingset[low, high]
|
||||||
private string inRange(string low, string high) {
|
private string getInRange(string low, string high) {
|
||||||
result = [toCodePoint(low) .. toCodePoint(high)].toUnicode()
|
result = [toCodePoint(low) .. toCodePoint(high)].toUnicode()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,7 +239,8 @@ module RangePrinter {
|
|||||||
isAlphanumeric(high)
|
isAlphanumeric(high)
|
||||||
then result = low + "-" + high
|
then result = low + "-" + high
|
||||||
else
|
else
|
||||||
result = strictconcat(string char | char = inRange(low, high) | escape(char) order by char)
|
result =
|
||||||
|
strictconcat(string char | char = getInRange(low, high) | escape(char) order by char)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user