Skip to content

Commit 585b864

Browse files
committed
ValidContainerElementAccess: Address new FPs
We had some new false positives because in 2.18.4 string taint is tracked into the qualifier of a string operation, such as insert. This caused us to erroneously identify the container itself as a reference to an element of the container. This has been addressed by excluding uses of the owning container from pointer or reference access.
1 parent f12bef5 commit 585b864

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

cpp/common/src/codingstandards/cpp/Iterators.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ class ContainerPointerOrReferenceAccess extends ContainerAccess {
3737
) and
3838
localTaint(DataFlow::exprNode(fc), DataFlow::exprNode(this)) and
3939
(getUnderlyingType() instanceof ReferenceType or getUnderlyingType() instanceof PointerType) and
40-
fc.getQualifier().(VariableAccess).getTarget() = owningContainer
40+
fc.getQualifier().(VariableAccess).getTarget() = owningContainer and
41+
// Exclude cases where we see taint into the owning container
42+
not this = owningContainer.getAnAccess()
4143
)
4244
}
4345

cpp/common/test/rules/validcontainerelementaccess/ValidContainerElementAccess.expected

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,4 @@
77
| test.cpp:89:15:89:16 | it | Elements of $@ not accessed with valid reference, pointer, or iterator because of a prior $@. | test.cpp:86:20:86:20 | d | container | test.cpp:92:7:92:12 | call to insert | invalidation |
88
| test.cpp:91:9:91:10 | it | Elements of $@ not accessed with valid reference, pointer, or iterator because of a prior $@. | test.cpp:86:20:86:20 | d | container | test.cpp:92:7:92:12 | call to insert | invalidation |
99
| test.cpp:98:56:98:58 | loc | Elements of $@ not accessed with valid reference, pointer, or iterator because of a prior $@. | test.cpp:96:44:96:46 | str | container | test.cpp:99:9:99:14 | call to insert | invalidation |
10-
| test.cpp:99:5:99:7 | str | Elements of $@ not accessed with valid reference, pointer, or iterator because of a prior $@. | test.cpp:96:44:96:46 | str | container | test.cpp:99:9:99:14 | call to insert | invalidation |
1110
| test.cpp:99:16:99:18 | loc | Elements of $@ not accessed with valid reference, pointer, or iterator because of a prior $@. | test.cpp:96:44:96:46 | str | container | test.cpp:99:9:99:14 | call to insert | invalidation |
12-
| test.cpp:106:11:106:13 | str | Elements of $@ not accessed with valid reference, pointer, or iterator because of a prior $@. | test.cpp:103:45:103:47 | str | container | test.cpp:106:15:106:20 | call to insert | invalidation |

0 commit comments

Comments
 (0)