@@ -19,10 +19,12 @@ module TaintTracking = CS::TaintTracking;
19
19
20
20
class Type = CS:: Type ;
21
21
22
+ class Callable = CS:: Callable ;
23
+
22
24
/**
23
25
* Holds if any of the parameters of `api` are `System.Func<>`.
24
26
*/
25
- private predicate isHigherOrder ( CS :: Callable api ) {
27
+ private predicate isHigherOrder ( Callable api ) {
26
28
exists ( Type t | t = api .getAParameter ( ) .getType ( ) .getUnboundDeclaration ( ) |
27
29
t instanceof SystemLinqExpressions:: DelegateExtType
28
30
)
@@ -32,23 +34,37 @@ private predicate irrelevantAccessor(CS::Accessor a) {
32
34
a .getDeclaration ( ) .( CS:: Property ) .isReadWrite ( )
33
35
}
34
36
37
+ private predicate isUninterestingForModels ( Callable api ) {
38
+ api .getDeclaringType ( ) .getNamespace ( ) .getFullName ( ) = "" or
39
+ api instanceof CS:: ConversionOperator or
40
+ api instanceof Util:: MainMethod or
41
+ api instanceof CS:: Destructor or
42
+ api instanceof CS:: AnonymousFunctionExpr or
43
+ api .( CS:: Constructor ) .isParameterless ( ) or
44
+ // Disregard properties that have both a get and a set accessor,
45
+ // which implicitly means auto implemented properties.
46
+ irrelevantAccessor ( api )
47
+ }
48
+
49
+ private predicate relevant ( Callable api ) {
50
+ [ api .( CS:: Modifiable ) , api .( CS:: Accessor ) .getDeclaration ( ) ] .isEffectivelyPublic ( ) and
51
+ api .fromSource ( ) and
52
+ api .isUnboundDeclaration ( ) and
53
+ not isUninterestingForModels ( api )
54
+ }
55
+
56
+ private predicate hasManualModel ( Callable api ) {
57
+ api = any ( FlowSummaryImpl:: Public:: SummarizedCallable sc | sc .applyManualModel ( ) ) or
58
+ api = any ( FlowSummaryImpl:: Public:: NeutralSummaryCallable sc | sc .hasManualModel ( ) )
59
+ }
60
+
35
61
/**
36
62
* Holds if it is relevant to generate models for `api`.
37
63
*/
38
- private predicate isRelevantForModels ( CS:: Callable api ) {
39
- [ api .( CS:: Modifiable ) , api .( CS:: Accessor ) .getDeclaration ( ) ] .isEffectivelyPublic ( ) and
40
- api .getDeclaringType ( ) .getNamespace ( ) .getFullName ( ) != "" and
41
- not api instanceof CS:: ConversionOperator and
42
- not api instanceof Util:: MainMethod and
43
- not api instanceof CS:: Destructor and
44
- not api instanceof CS:: AnonymousFunctionExpr and
45
- not api .( CS:: Constructor ) .isParameterless ( ) and
64
+ private predicate isRelevantForModels ( Callable api ) {
65
+ relevant ( api ) and
46
66
// Disregard all APIs that have a manual model.
47
- not api = any ( FlowSummaryImpl:: Public:: SummarizedCallable sc | sc .applyManualModel ( ) ) and
48
- not api = any ( FlowSummaryImpl:: Public:: NeutralSummaryCallable sc | sc .hasManualModel ( ) ) and
49
- // Disregard properties that have both a get and a set accessor,
50
- // which implicitly means auto implemented properties.
51
- not irrelevantAccessor ( api )
67
+ not hasManualModel ( api )
52
68
}
53
69
54
70
/**
@@ -72,11 +88,7 @@ predicate isUninterestingForTypeBasedFlowModels(CS::Callable api) { none() }
72
88
* from outside the library itself.
73
89
*/
74
90
class TargetApiSpecific extends CS:: Callable {
75
- TargetApiSpecific ( ) {
76
- this .fromSource ( ) and
77
- this .isUnboundDeclaration ( ) and
78
- isRelevantForModels ( this )
79
- }
91
+ TargetApiSpecific ( ) { isRelevantForModels ( this ) }
80
92
}
81
93
82
94
predicate asPartialModel = ExternalFlow:: asPartialModel / 1 ;
@@ -151,7 +163,7 @@ string paramReturnNodeAsOutput(CS::Callable c, ParameterPosition pos) {
151
163
/**
152
164
* Gets the enclosing callable of `ret`.
153
165
*/
154
- CS :: Callable returnNodeEnclosingCallable ( DataFlow:: Node ret ) {
166
+ Callable returnNodeEnclosingCallable ( DataFlow:: Node ret ) {
155
167
result = DataFlowImplCommon:: getNodeEnclosingCallable ( ret ) .asCallable ( )
156
168
}
157
169
0 commit comments