forked from github/securitylab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfield.qll
34 lines (33 loc) · 1.05 KB
/
field.qll
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import cpp
import common
import collections
import pointers.raw_ptr
/**
* An expression that assigns values to a general field. Can be an assignment,
* or an index expression that modifies a collection etc.
*/
Expr generalAssignValue(Field f) {
result = f.getAnAssignedValue() or
//normal assignment
exists(GeneralAssignment expr | expr.getLValue() = f.getAnAccess() and
expr.getRValue() = result
)
or
//Adding to a collection field
exists(FunctionCall fc | fc.getTarget() instanceof AddToCollection and result = fc.getAnArgument() and
getQualifier(fc) = f.getAnAccess()
)
or
//setting managed pointers.
exists(FunctionCall fc | fc.getTarget() instanceof ManagedPtrSetFunction and
getQualifier(fc) = f.getAnAccess() and
result = fc.getAnArgument()
)
or
//index operator to assign values to a collection field.
exists(FunctionCall indexer, GeneralAssignment expr | expr.getLValue() = indexer and
indexer.getTarget().hasName("operator[]") and
expr.getRValue() = result and
getQualifier(indexer) = f.getAnAccess()
)
}