|
2 | 2 | * @name Database query built from user-controlled sources |
3 | 3 | * @description Building a database query from user-controlled sources is vulnerable to insertion of |
4 | 4 | * malicious code by the user. |
5 | | -* @kind problem |
| 5 | +* @kind path-problem |
6 | 6 | * @problem.severity error |
7 | 7 | * @precision high |
8 | 8 | * @id js/sql-injection |
|
13 | 13 | import javascript |
14 | 14 | import semmle.javascript.security.dataflow.SqlInjection |
15 | 15 | import semmle.javascript.security.dataflow.NosqlInjection |
| 16 | +import DataFlow::PathGraph |
16 | 17 |
|
17 | | -predicate sqlInjection(DataFlow::Node source, DataFlow::Node sink) { |
18 | | - any(SqlInjection::Configuration cfg).hasFlow(source, sink) |
19 | | -} |
20 | | - |
21 | | -predicate nosqlInjection(DataFlow::Node source, DataFlow::Node sink) { |
22 | | - any(NosqlInjection::Configuration cfg).hasFlow(source, sink) |
23 | | -} |
24 | | - |
25 | | -from DataFlow::Node source, DataFlow::Node sink |
26 | | -where sqlInjection(source, sink) or |
27 | | - nosqlInjection(source, sink) |
28 | | -select sink, "This query depends on $@.", source, "a user-provided value" |
| 18 | +from DataFlow::Configuration cfg, DataFlow::PathNode source, DataFlow::PathNode sink |
| 19 | +where (cfg instanceof SqlInjection::Configuration or |
| 20 | + cfg instanceof NosqlInjection::Configuration) and |
| 21 | + cfg.hasPathFlow(source, sink) |
| 22 | +select sink.getNode(), source, sink, "This query depends on $@.", |
| 23 | + source.getNode(), "a user-provided value" |
0 commit comments