@@ -6,6 +6,7 @@ private import csharp as CS
66private import semmle.code.csharp.commons.Util as Util
77private import semmle.code.csharp.commons.Collections as Collections
88private import semmle.code.csharp.dataflow.internal.DataFlowDispatch
9+ private import semmle.code.csharp.frameworks.System as System
910import semmle.code.csharp.dataflow.ExternalFlow as ExternalFlow
1011import semmle.code.csharp.dataflow.internal.DataFlowImplCommon as DataFlowImplCommon
1112import semmle.code.csharp.dataflow.internal.DataFlowPrivate as DataFlowPrivate
@@ -16,14 +17,34 @@ module TaintTracking = CS::TaintTracking;
1617
1718class Type = CS:: Type ;
1819
20+ /**
21+ * Holds if `api` is an override or an interface implementation that
22+ * is irrelevant to the data flow analysis.
23+ */
24+ private predicate isIrrelevantOverrideOrImplementation ( CS:: Callable api ) {
25+ exists ( CS:: Callable exclude , CS:: Method m |
26+ (
27+ api = m .getAnOverrider * ( ) .getUnboundDeclaration ( )
28+ or
29+ api = m .getAnUltimateImplementor ( ) .getUnboundDeclaration ( )
30+ ) and
31+ exclude = m .getUnboundDeclaration ( )
32+ |
33+ exists ( System:: SystemObjectClass c | exclude = [ c .getGetHashCodeMethod ( ) , c .getEqualsMethod ( ) ] )
34+ or
35+ exists ( System:: SystemIEquatableTInterface i | exclude = i .getEqualsMethod ( ) )
36+ )
37+ }
38+
1939/**
2040 * Holds if it is relevant to generate models for `api`.
2141 */
2242private predicate isRelevantForModels ( CS:: Callable api ) {
2343 [ api .( CS:: Modifiable ) , api .( CS:: Accessor ) .getDeclaration ( ) ] .isEffectivelyPublic ( ) and
44+ api .getDeclaringType ( ) .getNamespace ( ) .getQualifiedName ( ) != "" and
2445 not api instanceof CS:: ConversionOperator and
2546 not api instanceof Util:: MainMethod and
26- api . getDeclaringType ( ) . getNamespace ( ) . getQualifiedName ( ) != ""
47+ not isIrrelevantOverrideOrImplementation ( api )
2748}
2849
2950/**
0 commit comments