JS: Fix template literal detection in string concatination

This commit is contained in:
Napalys Klicius
2025-06-12 11:18:20 +02:00
parent 861e4ee11e
commit bafe7e66ad
3 changed files with 5 additions and 6 deletions

View File

@@ -76,9 +76,10 @@ class CandidateStringLiteral extends StringLiteral {
* ```
*/
predicate hasObjectProvidingTemplateVariables(CandidateStringLiteral lit) {
exists(DataFlow::CallNode call, DataFlow::ObjectLiteralNode obj |
call.getAnArgument().getALocalSource() = obj and
call.getAnArgument().asExpr() = lit and
exists(DataFlow::CallNode call, DataFlow::ObjectLiteralNode obj, DataFlow::Node stringArg |
stringArg = [StringConcatenation::getRoot(lit.flow()), lit.flow()] and
stringArg = call.getAnArgument() and
obj.flowsTo(call.getAnArgument()) and
forex(string name | name = lit.getAReferencedVariable() | exists(obj.getAPropertyWrite(name)))
)
}