C#: Fix issue with summary tests, such that the output is compatiable with flow summary interpreter.

This commit is contained in:
Michael Nebel
2021-12-14 10:08:05 +01:00
parent 2cac729598
commit fc3299801b
3 changed files with 14 additions and 6 deletions

View File

@@ -357,9 +357,14 @@ private class UnboundValueOrRefType extends ValueOrRefType {
}
}
private class UnboundCallable extends Callable {
/** An unbound callable. */
class UnboundCallable extends Callable {
UnboundCallable() { this.isUnboundDeclaration() }
/**
* Holds if this unbound callable overrides or implements (transitively)
* `that` unbound callable.
*/
predicate overridesOrImplementsUnbound(UnboundCallable that) {
exists(Callable c |
this.(Virtualizable).overridesOrImplementsOrEquals(c) or

View File

@@ -1,4 +1,5 @@
import shared.FlowSummaries
private import semmle.code.csharp.dataflow.ExternalFlow
class IncludeFilteredSummarizedCallable extends IncludeSummarizedCallable {
IncludeFilteredSummarizedCallable() { this instanceof SummarizedCallable }
@@ -14,8 +15,8 @@ class IncludeFilteredSummarizedCallable extends IncludeSummarizedCallable {
this.propagatesFlow(input, output, preservesValue) and
not exists(IncludeSummarizedCallable rsc |
rsc.isBaseCallableOrPrototype() and
this.(Virtualizable).overridesOrImplements(rsc) and
rsc.propagatesFlow(input, output, preservesValue)
rsc.propagatesFlow(input, output, preservesValue) and
this.(UnboundCallable).overridesOrImplementsUnbound(rsc)
)
}
}

View File

@@ -20,9 +20,11 @@ abstract class IncludeSummarizedCallable extends RelevantSummarizedCallable {
predicate isBaseCallableOrPrototype() {
this.getDeclaringType() instanceof Interface
or
this.(Modifiable).isAbstract()
or
this.getDeclaringType().(Modifiable).isAbstract() and this.(Virtualizable).isVirtual()
exists(Modifiable m | m = [this.(Modifiable), this.(Accessor).getDeclaration()] |
m.isAbstract()
or
this.getDeclaringType().(Modifiable).isAbstract() and m.(Virtualizable).isVirtual()
)
}
/** Gets a string representing, whether the summary should apply for all overrides of this. */