2
2
* Provides predicates related to capturing summary models of the Standard or a 3rd party library.
3
3
*/
4
4
5
- import csharp
6
- private import semmle.code.csharp.dataflow.TaintTracking
5
+ private import csharp as CS
7
6
private import semmle.code.csharp.commons.Util as Util
8
- private import semmle.code.csharp.commons.Collections
7
+ private import semmle.code.csharp.commons.Collections as Collections
9
8
private import semmle.code.csharp.dataflow.internal.DataFlowDispatch
10
9
import semmle.code.csharp.dataflow.ExternalFlow as ExternalFlow
11
10
import semmle.code.csharp.dataflow.internal.DataFlowImplCommon as DataFlowImplCommon
12
11
import semmle.code.csharp.dataflow.internal.DataFlowPrivate as DataFlowPrivate
13
12
13
+ module DataFlow = CS:: DataFlow;
14
+
15
+ module TaintTracking = CS:: TaintTracking;
16
+
17
+ class Type = CS:: Type ;
18
+
14
19
/**
15
20
* Holds if it is relevant to generate models for `api`.
16
21
*/
17
- private predicate isRelevantForModels ( Callable api ) {
18
- [ api .( Modifiable ) , api .( Accessor ) .getDeclaration ( ) ] .isEffectivelyPublic ( ) and
22
+ private predicate isRelevantForModels ( CS :: Callable api ) {
23
+ [ api .( CS :: Modifiable ) , api .( CS :: Accessor ) .getDeclaration ( ) ] .isEffectivelyPublic ( ) and
19
24
not api instanceof Util:: MainMethod
20
25
}
21
26
@@ -38,10 +43,10 @@ predicate asPartialModel = DataFlowPrivate::Csv::asPartialModel/1;
38
43
* Holds for type `t` for fields that are relevant as an intermediate
39
44
* read or write step in the data flow analysis.
40
45
*/
41
- predicate isRelevantType ( Type t ) { not t instanceof Enum }
46
+ predicate isRelevantType ( CS :: Type t ) { not t instanceof CS :: Enum }
42
47
43
- private string parameterAccess ( Parameter p ) {
44
- if isCollectionType ( p .getType ( ) )
48
+ private string parameterAccess ( CS :: Parameter p ) {
49
+ if Collections :: isCollectionType ( p .getType ( ) )
45
50
then result = "Argument[" + p .getPosition ( ) + "].Element"
46
51
else result = "Argument[" + p .getPosition ( ) + "]"
47
52
}
@@ -56,7 +61,7 @@ string parameterNodeAsInput(DataFlow::ParameterNode p) {
56
61
}
57
62
58
63
pragma [ nomagic]
59
- private Parameter getParameter ( DataFlowImplCommon:: ReturnNodeExt node , ParameterPosition pos ) {
64
+ private CS :: Parameter getParameter ( DataFlowImplCommon:: ReturnNodeExt node , ParameterPosition pos ) {
60
65
result = node .getEnclosingCallable ( ) .getParameter ( pos .getPosition ( ) )
61
66
}
62
67
@@ -80,15 +85,15 @@ string returnNodeAsOutput(DataFlowImplCommon::ReturnNodeExt node) {
80
85
/**
81
86
* Gets the enclosing callable of `ret`.
82
87
*/
83
- Callable returnNodeEnclosingCallable ( DataFlowImplCommon:: ReturnNodeExt ret ) {
88
+ CS :: Callable returnNodeEnclosingCallable ( DataFlowImplCommon:: ReturnNodeExt ret ) {
84
89
result = DataFlowImplCommon:: getNodeEnclosingCallable ( ret )
85
90
}
86
91
87
92
/**
88
93
* Holds if `node` is an own instance access.
89
94
*/
90
95
predicate isOwnInstanceAccessNode ( DataFlowPrivate:: ReturnNode node ) {
91
- node .asExpr ( ) instanceof ThisAccess
96
+ node .asExpr ( ) instanceof CS :: ThisAccess
92
97
}
93
98
94
99
/**
@@ -105,17 +110,17 @@ predicate isRelevantSinkKind(string kind) { any() }
105
110
/**
106
111
* Language specific parts of the `PropagateToSinkConfiguration`.
107
112
*/
108
- class PropagateToSinkConfigurationSpecific extends TaintTracking:: Configuration {
113
+ class PropagateToSinkConfigurationSpecific extends CS :: TaintTracking:: Configuration {
109
114
PropagateToSinkConfigurationSpecific ( ) { this = "parameters or fields flowing into sinks" }
110
115
111
116
private predicate isRelevantMemberAccess ( DataFlow:: Node node ) {
112
- exists ( MemberAccess access | access = node .asExpr ( ) |
117
+ exists ( CS :: MemberAccess access | access = node .asExpr ( ) |
113
118
access .hasThisQualifier ( ) and
114
119
access .getTarget ( ) .isEffectivelyPublic ( ) and
115
120
(
116
- access instanceof FieldAccess
121
+ access instanceof CS :: FieldAccess
117
122
or
118
- access .getTarget ( ) .( Property ) .getSetter ( ) .isPublic ( )
123
+ access .getTarget ( ) .( CS :: Property ) .getSetter ( ) .isPublic ( )
119
124
)
120
125
)
121
126
}
0 commit comments