@@ -19,10 +19,12 @@ module TaintTracking = CS::TaintTracking;
1919
2020class Type = CS:: Type ;
2121
22+ class Callable = CS:: Callable ;
23+
2224/**
2325 * Holds if any of the parameters of `api` are `System.Func<>`.
2426 */
25- private predicate isHigherOrder ( CS :: Callable api ) {
27+ private predicate isHigherOrder ( Callable api ) {
2628 exists ( Type t | t = api .getAParameter ( ) .getType ( ) .getUnboundDeclaration ( ) |
2729 t instanceof SystemLinqExpressions:: DelegateExtType
2830 )
@@ -32,23 +34,37 @@ private predicate irrelevantAccessor(CS::Accessor a) {
3234 a .getDeclaration ( ) .( CS:: Property ) .isReadWrite ( )
3335}
3436
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+
3561/**
3662 * Holds if it is relevant to generate models for `api`.
3763 */
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
4666 // 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 )
5268}
5369
5470/**
@@ -72,11 +88,7 @@ predicate isUninterestingForTypeBasedFlowModels(CS::Callable api) { none() }
7288 * from outside the library itself.
7389 */
7490class TargetApiSpecific extends CS:: Callable {
75- TargetApiSpecific ( ) {
76- this .fromSource ( ) and
77- this .isUnboundDeclaration ( ) and
78- isRelevantForModels ( this )
79- }
91+ TargetApiSpecific ( ) { isRelevantForModels ( this ) }
8092}
8193
8294predicate asPartialModel = ExternalFlow:: asPartialModel / 1 ;
@@ -151,7 +163,7 @@ string paramReturnNodeAsOutput(CS::Callable c, ParameterPosition pos) {
151163/**
152164 * Gets the enclosing callable of `ret`.
153165 */
154- CS :: Callable returnNodeEnclosingCallable ( DataFlow:: Node ret ) {
166+ Callable returnNodeEnclosingCallable ( DataFlow:: Node ret ) {
155167 result = DataFlowImplCommon:: getNodeEnclosingCallable ( ret ) .asCallable ( )
156168}
157169
0 commit comments