Skip to content

Commit

Permalink
Merge pull request #17053 from owen-mc/java/fix/regex-use-sink-kind
Browse files Browse the repository at this point in the history
Java: Add comments about use of sink kind `regex-use`
  • Loading branch information
owen-mc committed Jul 24, 2024
2 parents 90b25a6 + 3edeb82 commit 5a39610
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions java/ql/lib/ext/org.apache.commons.lang3.model.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ extensions:
pack: codeql/java-all
extensible: sinkModel
data:
# Note these sinks do not use the sink kind `regex-use[0]` because they should be considered as sinks for regex injection but not polynomial ReDoS.
- ["org.apache.commons.lang3", "RegExUtils", False, "removeAll", "(String,String)", "", "Argument[1]", "regex-use", "manual"]
- ["org.apache.commons.lang3", "RegExUtils", False, "removeFirst", "(String,String)", "", "Argument[1]", "regex-use", "manual"]
- ["org.apache.commons.lang3", "RegExUtils", False, "removePattern", "(String,String)", "", "Argument[1]", "regex-use", "manual"]
Expand Down
12 changes: 9 additions & 3 deletions java/ql/lib/semmle/code/java/regex/RegexFlowConfigs.qll
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ private class ExploitableStringLiteral extends StringLiteral {

/**
* Holds if `kind` is an external sink kind that is relevant for regex flow.
* `full` is true if sinks with this kind match against the full string of its input.
* `strArg` is the index of the argument to methods with this sink kind that contan the string to be matched against,
* where -1 is the qualifier; or -2 if no such argument exists.
* `full` is true if sinks with this kind match against the full string of its
* input.
* `strArg` is the index of the argument to methods with this sink kind that
* contain the string to be matched against, where -1 is the qualifier; or -2
* if no such argument exists.
*
* Note that `regex-use` is deliberately not a possible value for `kind` here,
* as it is used for regular expression injection sinks that should not be used
* as polynomial ReDoS sinks.
*/
private predicate regexSinkKindInfo(string kind, boolean full, int strArg) {
sinkModel(_, _, _, _, _, _, _, kind, _, _) and
Expand Down

0 comments on commit 5a39610

Please sign in to comment.