Skip to content

Commit 43738d5

Browse files
committed
Get the query depending on the type of sink
1 parent 89522d0 commit 43738d5

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

javascript/frameworks/cap/src/cqlinjection/CqlInjection.ql

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,26 @@ import javascript
1414
import DataFlow::PathGraph
1515
import advanced_security.javascript.frameworks.cap.CAPCqlInjectionQuery
1616

17+
DataFlow::Node getQueryOfSink(DataFlow::Node sink) {
18+
exists(CqlRunMethodCall cqlRunMethodCall |
19+
sink = cqlRunMethodCall.(CqlRunMethodCall).getAQueryParameter() and
20+
result = sink
21+
)
22+
or
23+
exists(CqlShortcutMethodCallWithStringConcat shortcutCall |
24+
sink = shortcutCall.(CqlQueryRunnerCall).getAQueryParameter() and
25+
result = shortcutCall
26+
)
27+
or
28+
exists(AwaitExpr await, CqlClauseWithStringConcatParameter cqlClauseWithStringConcat |
29+
sink = await.flow() and
30+
await.getOperand() = cqlClauseWithStringConcat.(CqlClause).asExpr() and
31+
result = cqlClauseWithStringConcat.(CqlClause).flow()
32+
)
33+
}
34+
1735
from CqlInjectionConfiguration sql, DataFlow::PathNode source, DataFlow::PathNode sink
1836
where sql.hasFlowPath(source, sink)
1937
/* TODO: Print different message if sink is `CqlShortcutMethodCallWithStringConcat` */
20-
select sink.getNode(), source, sink, "This CQL query depends on a $@.", source.getNode(),
21-
"user-provided value"
38+
select getQueryOfSink(sink.getNode()), source, sink, "This CQL query depends on a $@.",
39+
source.getNode(), "user-provided value"

0 commit comments

Comments
 (0)