|
4 | 4 |
|
5 | 5 | import TestUtilities.InlineExpectationsTest |
6 | 6 | import semmle.code.cpp.dataflow.DataFlow |
7 | | -import DataFlow |
| 7 | +import ASTConfiguration |
8 | 8 | import cpp |
9 | 9 |
|
10 | | -class Conf extends Configuration { |
11 | | - Conf() { this = "FieldFlowConf" } |
12 | | - |
13 | | - override predicate isSource(Node src) { |
14 | | - src.asExpr() instanceof NewExpr |
15 | | - or |
16 | | - src.asExpr().(Call).getTarget().hasName("user_input") |
17 | | - or |
18 | | - exists(FunctionCall fc | |
19 | | - fc.getAnArgument() = src.asDefiningArgument() and |
20 | | - fc.getTarget().hasName("argument_source") |
21 | | - ) |
22 | | - } |
23 | | - |
24 | | - override predicate isSink(Node sink) { |
25 | | - exists(Call c | |
26 | | - c.getTarget().hasName("sink") and |
27 | | - c.getAnArgument() = sink.asExpr() |
28 | | - ) |
29 | | - } |
30 | | - |
31 | | - override predicate isAdditionalFlowStep(Node a, Node b) { |
32 | | - b.asPartialDefinition() = |
33 | | - any(Call c | c.getTarget().hasName("insert") and c.getAnArgument() = a.asExpr()) |
34 | | - .getQualifier() |
35 | | - or |
36 | | - b.asExpr().(AddressOfExpr).getOperand() = a.asExpr() |
37 | | - } |
38 | | -} |
39 | | - |
40 | 10 | class ASTFieldFlowTest extends InlineExpectationsTest { |
41 | 11 | ASTFieldFlowTest() { this = "ASTFieldFlowTest" } |
42 | 12 |
|
43 | 13 | override string getARelevantTag() { result = "ast" } |
44 | 14 |
|
45 | 15 | override predicate hasActualResult(Location location, string element, string tag, string value) { |
46 | | - exists(Node source, Node sink, Conf conf, int n | |
| 16 | + exists(DataFlow::Node source, DataFlow::Node sink, Conf conf, int n | |
47 | 17 | tag = "ast" and |
48 | 18 | conf.hasFlow(source, sink) and |
49 | | - n = strictcount(Node otherSource | conf.hasFlow(otherSource, sink)) and |
| 19 | + n = strictcount(DataFlow::Node otherSource | conf.hasFlow(otherSource, sink)) and |
50 | 20 | ( |
51 | 21 | n = 1 and value = "" |
52 | 22 | or |
|
0 commit comments