Skip to content

Commit f7c29e6

Browse files
committed
C++: Expose some previously private classes from our models so they can be used in queries.
1 parent 693c28a commit f7c29e6

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

cpp/ql/lib/semmle/code/cpp/models/implementations/Iterator.qll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,15 +438,19 @@ private class IteratorAssignmentMemberOperatorModel extends IteratorAssignmentMe
438438
* A `begin` or `end` member function, or a related member function, that
439439
* returns an iterator.
440440
*/
441-
private class BeginOrEndFunction extends MemberFunction, TaintFunction, GetIteratorFunction {
441+
class BeginOrEndFunction extends MemberFunction {
442442
BeginOrEndFunction() {
443443
this.hasName([
444444
"begin", "cbegin", "rbegin", "crbegin", "end", "cend", "rend", "crend", "before_begin",
445445
"cbefore_begin"
446446
]) and
447447
this.getType().getUnspecifiedType() instanceof Iterator
448448
}
449+
}
449450

451+
private class BeginOrEndFunctionModels extends BeginOrEndFunction, TaintFunction,
452+
GetIteratorFunction
453+
{
450454
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
451455
input.isQualifierObject() and
452456
output.isReturnValue()

cpp/ql/lib/semmle/code/cpp/models/implementations/StdContainer.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,15 @@ private class StdSequenceContainerAssign extends TaintFunction {
253253
/**
254254
* The standard container functions `at` and `operator[]`.
255255
*/
256-
private class StdSequenceContainerAt extends TaintFunction {
256+
class StdSequenceContainerAt extends MemberFunction {
257257
StdSequenceContainerAt() {
258258
this.getClassAndName(["at", "operator[]"]) instanceof Array or
259259
this.getClassAndName(["at", "operator[]"]) instanceof Deque or
260260
this.getClassAndName(["at", "operator[]"]) instanceof Vector
261261
}
262+
}
262263

264+
private class StdSequenceContainerAtModel extends StdSequenceContainerAt, TaintFunction {
263265
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
264266
// flow from qualifier to referenced return value
265267
input.isQualifierObject() and

cpp/ql/lib/semmle/code/cpp/models/implementations/StdMap.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,11 @@ private class StdMapMerge extends TaintFunction {
129129
/**
130130
* The standard map functions `at` and `operator[]`.
131131
*/
132-
private class StdMapAt extends TaintFunction {
132+
class StdMapAt extends MemberFunction {
133133
StdMapAt() { this.getClassAndName(["at", "operator[]"]) instanceof MapOrUnorderedMap }
134+
}
134135

136+
private class StdMapAtModels extends StdMapAt, TaintFunction {
135137
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
136138
// flow from qualifier to referenced return value
137139
input.isQualifierObject() and

0 commit comments

Comments
 (0)