mirror of
https://github.com/github/codeql.git
synced 2026-05-01 19:55:15 +02:00
Merge pull request #9255 from michaelnebel/csharp/test-clearscontent
C#: Remove default clears content.
This commit is contained in:
@@ -139,28 +139,6 @@ private class RecordConstructorFlow extends SummarizedCallable {
|
||||
}
|
||||
}
|
||||
|
||||
private class SummarizedCallableDefaultClearsContent extends Impl::Public::SummarizedCallable {
|
||||
SummarizedCallableDefaultClearsContent() {
|
||||
this instanceof Impl::Public::SummarizedCallable or none()
|
||||
}
|
||||
|
||||
// By default, we assume that all stores into arguments are definite
|
||||
override predicate clearsContent(ParameterPosition pos, DataFlow::ContentSet content) {
|
||||
exists(SummaryComponentStack output, SummaryComponent target |
|
||||
this.propagatesFlow(_, output, _) and
|
||||
output.drop(_) =
|
||||
SummaryComponentStack::push(SummaryComponent::content(content),
|
||||
SummaryComponentStack::singleton(target)) and
|
||||
not content instanceof DataFlow::ElementContent
|
||||
|
|
||||
target = SummaryComponent::argument(pos.getPosition())
|
||||
or
|
||||
target = SummaryComponent::qualifier() and
|
||||
pos.isThisParameter()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
class RequiredSummaryComponentStack = Impl::Public::RequiredSummaryComponentStack;
|
||||
|
||||
private class RecordConstructorFlowRequiredSummaryComponentStack extends RequiredSummaryComponentStack {
|
||||
|
||||
@@ -933,7 +933,8 @@ module Private {
|
||||
summaryElement(this, inSpec, outSpec, kind, false)
|
||||
or
|
||||
summaryElement(this, inSpec, outSpec, kind, true) and
|
||||
not summaryElement(this, _, _, _, false)
|
||||
not summaryElement(this, _, _, _, false) and
|
||||
not this.clearsContent(_, _)
|
||||
}
|
||||
|
||||
override predicate propagatesFlow(
|
||||
|
||||
@@ -20,5 +20,5 @@ summarySetterStep
|
||||
| Steps.cs:34:37:34:37 | 0 | Steps.cs:34:13:34:16 | [post] this access | Steps.cs:63:13:63:20 | property Property |
|
||||
| Steps.cs:38:36:38:36 | 0 | Steps.cs:38:13:38:16 | [post] this access | file://:0:0:0:0 | element |
|
||||
clearsContent
|
||||
| Steps.cs:61:14:61:28 | StepFieldSetter | Steps.cs:57:13:57:17 | field Field | this |
|
||||
| Steps.cs:67:14:67:31 | StepPropertySetter | Steps.cs:63:13:63:20 | property Property | this |
|
||||
| Steps.cs:61:14:61:28 | StepFieldSetter | file://:0:0:0:0 | element | this |
|
||||
| Steps.cs:67:14:67:31 | StepPropertySetter | file://:0:0:0:0 | element | this |
|
||||
|
||||
@@ -5,7 +5,7 @@ import semmle.code.csharp.dataflow.FlowSummary
|
||||
import semmle.code.csharp.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
|
||||
import CsvValidation
|
||||
|
||||
class SummaryModelTest extends SummaryModelCsv {
|
||||
private class SummaryModelTest extends SummaryModelCsv {
|
||||
override predicate row(string row) {
|
||||
row =
|
||||
[
|
||||
@@ -28,6 +28,18 @@ class SummaryModelTest extends SummaryModelCsv {
|
||||
}
|
||||
}
|
||||
|
||||
private class SummarizedCallableClear extends SummarizedCallable {
|
||||
SummarizedCallableClear() {
|
||||
this.getName() = ["StepPropertySetter", "StepFieldSetter"] and
|
||||
this.getFile().getBaseName() = "Steps.cs"
|
||||
}
|
||||
|
||||
override predicate clearsContent(ParameterPosition pos, DataFlow::ContentSet content) {
|
||||
pos.isThisParameter() and
|
||||
content instanceof DataFlow::ElementContent
|
||||
}
|
||||
}
|
||||
|
||||
query predicate summaryThroughStep(
|
||||
DataFlow::Node node1, DataFlow::Node node2, boolean preservesValue
|
||||
) {
|
||||
|
||||
@@ -933,7 +933,8 @@ module Private {
|
||||
summaryElement(this, inSpec, outSpec, kind, false)
|
||||
or
|
||||
summaryElement(this, inSpec, outSpec, kind, true) and
|
||||
not summaryElement(this, _, _, _, false)
|
||||
not summaryElement(this, _, _, _, false) and
|
||||
not this.clearsContent(_, _)
|
||||
}
|
||||
|
||||
override predicate propagatesFlow(
|
||||
|
||||
@@ -933,7 +933,8 @@ module Private {
|
||||
summaryElement(this, inSpec, outSpec, kind, false)
|
||||
or
|
||||
summaryElement(this, inSpec, outSpec, kind, true) and
|
||||
not summaryElement(this, _, _, _, false)
|
||||
not summaryElement(this, _, _, _, false) and
|
||||
not this.clearsContent(_, _)
|
||||
}
|
||||
|
||||
override predicate propagatesFlow(
|
||||
|
||||
Reference in New Issue
Block a user