Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions csharp/ql/lib/semmle/code/csharp/dataflow/FlowSummary.qll
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
14 changes: 13 additions & 1 deletion csharp/ql/test/library-tests/dataflow/external-models/steps.ql
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
[
Expand All @@ -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
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down