File tree Expand file tree Collapse file tree 5 files changed +28
-2
lines changed
src/semmle/code/cpp/models/implementations
test/library-tests/dataflow/taint-tests Expand file tree Collapse file tree 5 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -12,3 +12,19 @@ class StdStringCStr extends TaintFunction {
12
12
output .isReturnValue ( )
13
13
}
14
14
}
15
+
16
+ /**
17
+ * The `std::string` function `append`.
18
+ */
19
+ class StdStringAppend extends TaintFunction {
20
+ StdStringAppend ( ) { this .hasQualifiedName ( "std" , "basic_string" , "append" ) }
21
+
22
+ override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
23
+ // flow from parameter to string itself (qualifier) and return value
24
+ input .isParameterDeref ( 0 ) and
25
+ (
26
+ output .isQualifierObject ( ) or
27
+ output .isReturnValueDeref ( )
28
+ )
29
+ }
30
+ }
Original file line number Diff line number Diff line change 546
546
| stl.cpp:351:8:351:9 | s3 | stl.cpp:352:3:352:4 | s8 | |
547
547
| stl.cpp:351:8:351:9 | s3 | stl.cpp:353:8:353:9 | s8 | |
548
548
| stl.cpp:352:3:352:4 | ref arg s8 | stl.cpp:353:8:353:9 | s8 | |
549
+ | stl.cpp:352:13:352:14 | s4 | stl.cpp:352:3:352:4 | ref arg s8 | TAINT |
550
+ | stl.cpp:352:13:352:14 | s4 | stl.cpp:352:6:352:11 | call to append | TAINT |
549
551
| stl.cpp:355:8:355:9 | s3 | stl.cpp:355:3:355:9 | ... = ... | |
550
552
| stl.cpp:355:8:355:9 | s3 | stl.cpp:356:3:356:4 | s9 | |
551
553
| stl.cpp:355:8:355:9 | s3 | stl.cpp:357:3:357:4 | s9 | |
552
554
| stl.cpp:355:8:355:9 | s3 | stl.cpp:358:8:358:9 | s9 | |
553
555
| stl.cpp:356:3:356:4 | ref arg s9 | stl.cpp:357:3:357:4 | s9 | |
554
556
| stl.cpp:356:3:356:4 | ref arg s9 | stl.cpp:358:8:358:9 | s9 | |
557
+ | stl.cpp:356:13:356:18 | call to source | stl.cpp:356:3:356:4 | ref arg s9 | TAINT |
558
+ | stl.cpp:356:13:356:18 | call to source | stl.cpp:356:6:356:11 | call to append | TAINT |
555
559
| stl.cpp:357:3:357:4 | ref arg s9 | stl.cpp:358:8:358:9 | s9 | |
560
+ | stl.cpp:357:13:357:15 | | stl.cpp:357:3:357:4 | ref arg s9 | TAINT |
561
+ | stl.cpp:357:13:357:15 | | stl.cpp:357:6:357:11 | call to append | TAINT |
556
562
| structlikeclass.cpp:5:7:5:7 | Unknown literal | structlikeclass.cpp:5:7:5:7 | constructor init of field v | TAINT |
557
563
| structlikeclass.cpp:5:7:5:7 | Unknown literal | structlikeclass.cpp:5:7:5:7 | constructor init of field v | TAINT |
558
564
| structlikeclass.cpp:5:7:5:7 | this | structlikeclass.cpp:5:7:5:7 | constructor init of field v [pre-this] | |
Original file line number Diff line number Diff line change @@ -350,11 +350,11 @@ void test_string_append() {
350
350
351
351
s8 = s3;
352
352
s8.append (s4);
353
- sink (s8); // tainted [NOT DETECTED]
353
+ sink (s8); // tainted
354
354
355
355
s9 = s3;
356
356
s9.append (source ());
357
357
s9.append (" " );
358
- sink (s9); // tainted [NOT DETECTED]
358
+ sink (s9); // tainted
359
359
}
360
360
}
Original file line number Diff line number Diff line change 53
53
| stl.cpp:303:8:303:8 | x | stl.cpp:296:43:296:49 | source1 |
54
54
| stl.cpp:311:8:311:8 | x | stl.cpp:296:43:296:49 | source1 |
55
55
| stl.cpp:316:8:316:8 | x | stl.cpp:296:43:296:49 | source1 |
56
+ | stl.cpp:353:8:353:9 | s8 | stl.cpp:336:18:336:23 | call to source |
57
+ | stl.cpp:358:8:358:9 | s9 | stl.cpp:356:13:356:18 | call to source |
56
58
| structlikeclass.cpp:35:8:35:9 | s1 | structlikeclass.cpp:29:22:29:27 | call to source |
57
59
| structlikeclass.cpp:36:8:36:9 | s2 | structlikeclass.cpp:30:24:30:29 | call to source |
58
60
| structlikeclass.cpp:37:8:37:9 | s3 | structlikeclass.cpp:29:22:29:27 | call to source |
Original file line number Diff line number Diff line change 50
50
| stl.cpp:303:8:303:8 | stl.cpp:296:43:296:49 | AST only |
51
51
| stl.cpp:311:8:311:8 | stl.cpp:296:43:296:49 | AST only |
52
52
| stl.cpp:316:8:316:8 | stl.cpp:296:43:296:49 | AST only |
53
+ | stl.cpp:353:8:353:9 | stl.cpp:336:18:336:23 | AST only |
54
+ | stl.cpp:358:8:358:9 | stl.cpp:356:13:356:18 | AST only |
53
55
| structlikeclass.cpp:35:8:35:9 | structlikeclass.cpp:29:22:29:27 | AST only |
54
56
| structlikeclass.cpp:36:8:36:9 | structlikeclass.cpp:30:24:30:29 | AST only |
55
57
| structlikeclass.cpp:37:8:37:9 | structlikeclass.cpp:29:22:29:27 | AST only |
You can’t perform that action at this time.
0 commit comments