Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions javascript/ql/src/semmle/javascript/Expr.qll
Original file line number Diff line number Diff line change
Expand Up @@ -1603,17 +1603,26 @@ private predicate hasAllConstantLeafs(AddExpr add) {
private string getConcatenatedString(Expr add) {
result = getConcatenatedString(add.getUnderlyingValue())
or
not add = getAnAddOperand(any(AddExpr parent | hasAllConstantLeafs(parent))) and
hasAllConstantLeafs(add) and
result =
strictconcat(Expr leaf |
leaf = getAnAddOperand*(add)
leaf = getAnAddOperand*(add.(SmallConcatRoot))
|
getConstantString(leaf)
order by
leaf.getLocation().getStartLine(), leaf.getLocation().getStartColumn()
) and
result.length() < 1000 * 1000
)
}

/**
* An expr that is the root of a string concatenation of constant parts,
* and the length of the resulting concatenation is less than 1 million chars.
*/
private class SmallConcatRoot extends Expr {
SmallConcatRoot() {
not this = getAnAddOperand(any(AddExpr parent | hasAllConstantLeafs(parent))) and
hasAllConstantLeafs(this) and
sum(Expr leaf | leaf = getAnAddOperand*(this) | getConstantString(leaf).length()) < 1000 * 1000
}
}

/**
Expand Down