Skip to content

Commit c0b04ea

Browse files
committed
C++: Add failing test.
1 parent e301223 commit c0b04ea

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

cpp/ql/test/library-tests/dataflow/taint-tests/localTaint.expected

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2199,6 +2199,19 @@ WARNING: Module TaintTracking has been deprecated and may be removed in future (
21992199
| map.cpp:436:55:436:59 | def | map.cpp:436:19:436:60 | call to pair | TAINT |
22002200
| map.cpp:436:63:436:67 | first | map.cpp:436:7:436:67 | call to iterator | |
22012201
| map.cpp:437:7:437:9 | m35 | map.cpp:437:7:437:9 | call to unordered_map | |
2202+
| map.cpp:446:23:446:23 | call to map | map.cpp:448:3:448:3 | m | |
2203+
| map.cpp:446:23:446:23 | call to map | map.cpp:449:12:449:12 | m | |
2204+
| map.cpp:446:23:446:23 | call to map | map.cpp:451:1:451:1 | m | |
2205+
| map.cpp:447:12:447:26 | call to indirect_source | map.cpp:448:10:448:10 | p | |
2206+
| map.cpp:448:3:448:3 | m | map.cpp:448:4:448:4 | call to operator[] | TAINT |
2207+
| map.cpp:448:3:448:3 | ref arg m | map.cpp:449:12:449:12 | m | |
2208+
| map.cpp:448:3:448:3 | ref arg m | map.cpp:451:1:451:1 | m | |
2209+
| map.cpp:448:3:448:10 | ... = ... | map.cpp:448:4:448:4 | call to operator[] [post update] | |
2210+
| map.cpp:448:4:448:4 | call to operator[] [post update] | map.cpp:448:3:448:3 | ref arg m | TAINT |
2211+
| map.cpp:448:10:448:10 | p | map.cpp:448:3:448:10 | ... = ... | |
2212+
| map.cpp:449:12:449:12 | m | map.cpp:449:13:449:13 | call to operator[] | TAINT |
2213+
| map.cpp:449:12:449:12 | ref arg m | map.cpp:451:1:451:1 | m | |
2214+
| map.cpp:449:13:449:13 | call to operator[] | map.cpp:450:8:450:8 | q | |
22022215
| movableclass.cpp:8:2:8:15 | this | movableclass.cpp:8:27:8:31 | constructor init of field v [pre-this] | |
22032216
| movableclass.cpp:8:21:8:22 | _v | movableclass.cpp:8:29:8:30 | _v | |
22042217
| movableclass.cpp:8:29:8:30 | _v | movableclass.cpp:8:27:8:31 | constructor init of field v | TAINT |

cpp/ql/test/library-tests/dataflow/taint-tests/map.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,3 +436,16 @@ void test_unordered_map()
436436
sink(m35.emplace(std::pair<char *, char *>(source(), "def")).first); // $ MISSING: ast,ir
437437
sink(m35); // $ MISSING: ast,ir
438438
}
439+
440+
namespace {
441+
int* indirect_source();
442+
void indirect_sink(int*);
443+
}
444+
445+
void test_indirect_taint() {
446+
std::map<int, int*> m;
447+
int* p = indirect_source();
448+
m[1] = p;
449+
int* q = m[1];
450+
sink(q); // $ MISSING: ast ir
451+
}

cpp/ql/test/library-tests/dataflow/taint-tests/taint.ql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ module IRTest {
8484
or
8585
source.asIndirectExpr().(FunctionCall).getTarget().getName() = "source"
8686
or
87+
source.asIndirectExpr().(FunctionCall).getTarget().getName() = "indirect_source"
88+
or
8789
source.asParameter().getName().matches("source%")
8890
or
8991
exists(FunctionCall fc |

0 commit comments

Comments
 (0)