mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
JS: Avoid bad join in shared predicate induced by 'forex'.
Use manual recursion instead.
This commit is contained in:
@@ -1648,13 +1648,19 @@ private string getConstantString(Expr e) {
|
|||||||
result = e.(TemplateElement).getValue()
|
result = e.(TemplateElement).getValue()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pragma[nomagic]
|
||||||
|
private predicate hasConstantStringValue(Expr e) {
|
||||||
|
exists(getConstantString(e))
|
||||||
|
or
|
||||||
|
hasAllConstantLeafs(e.getUnderlyingValue())
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds if `add` is a string-concatenation where all the transitive leafs have a constant string value.
|
* Holds if `add` is a string-concatenation where all the transitive leafs have a constant string value.
|
||||||
*/
|
*/
|
||||||
private predicate hasAllConstantLeafs(AddExpr add) {
|
private predicate hasAllConstantLeafs(AddExpr add) {
|
||||||
forex(Expr leaf | leaf = getAnAddOperand*(add) and not exists(getAnAddOperand(leaf)) |
|
hasConstantStringValue(add.getLeftOperand()) and
|
||||||
exists(getConstantString(leaf))
|
hasConstantStringValue(add.getRightOperand())
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user