From bbab0e582a2796063e33f5c20773a47840237e97 Mon Sep 17 00:00:00 2001 From: Michael Nebel Date: Fri, 3 Dec 2021 13:42:23 +0100 Subject: [PATCH] C#: Convert System.Lazy<> flow to CSV format. --- .../csharp/dataflow/LibraryTypeDataFlow.qll | 25 ------------------- .../semmle/code/csharp/frameworks/System.qll | 13 ++++++++++ 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/csharp/ql/lib/semmle/code/csharp/dataflow/LibraryTypeDataFlow.qll b/csharp/ql/lib/semmle/code/csharp/dataflow/LibraryTypeDataFlow.qll index e2a5f0755bc..087efac40ca 100644 --- a/csharp/ql/lib/semmle/code/csharp/dataflow/LibraryTypeDataFlow.qll +++ b/csharp/ql/lib/semmle/code/csharp/dataflow/LibraryTypeDataFlow.qll @@ -546,31 +546,6 @@ class SystemTextStringBuilderFlow extends LibraryTypeDataFlow, SystemTextStringB } } -/** Data flow for `System.Lazy<>`. */ -class SystemLazyFlow extends LibraryTypeDataFlow, SystemLazyClass { - override predicate callableFlow( - CallableFlowSource source, AccessPath sourceAp, CallableFlowSink sink, AccessPath sinkAp, - SourceDeclarationCallable c, boolean preservesValue - ) { - preservesValue = true and - exists(SystemFuncDelegateType t, int i | t.getNumberOfTypeParameters() = 1 | - c.(Constructor).getDeclaringType() = this and - c.getParameter(i).getType().getUnboundDeclaration() = t and - source = getDelegateFlowSourceArg(c, i) and - sourceAp = AccessPath::empty() and - sink = TCallableFlowSinkReturn() and - sinkAp = AccessPath::property(this.getValueProperty()) - ) - or - preservesValue = false and - c = this.getValueProperty().getGetter() and - source = TCallableFlowSourceQualifier() and - sourceAp = AccessPath::empty() and - sink = TCallableFlowSinkReturn() and - sinkAp = AccessPath::empty() - } -} - /** Data flow for `System.Nullable<>`. */ class SystemNullableFlow extends LibraryTypeDataFlow, SystemNullableStruct { override predicate callableFlow( diff --git a/csharp/ql/lib/semmle/code/csharp/frameworks/System.qll b/csharp/ql/lib/semmle/code/csharp/frameworks/System.qll index 727458216d6..b9ba1c71f19 100644 --- a/csharp/ql/lib/semmle/code/csharp/frameworks/System.qll +++ b/csharp/ql/lib/semmle/code/csharp/frameworks/System.qll @@ -257,6 +257,19 @@ class SystemLazyClass extends SystemUnboundGenericClass { } } +/** Data flow for `System.Lazy<>`. */ +private class SystemLazyFlowModelCsv extends SummaryModelCsv { + override predicate row(string row) { + row = + [ + "System;Lazy<>;false;Lazy;(System.Func);;ReturnValue of Argument[0];Property[System.Lazy<>.Value] of ReturnValue;value", + "System;Lazy<>;false;Lazy;(System.Func,System.Boolean);;ReturnValue of Argument[0];Property[System.Lazy<>.Value] of ReturnValue;value", + "System;Lazy<>;false;Lazy;(System.Func,System.Threading.LazyThreadSafetyMode);;ReturnValue of Argument[0];Property[System.Lazy<>.Value] of ReturnValue;value", + "System;Lazy<>;false;get_Value;();;Argument[-1];ReturnValue;taint", + ] + } +} + /** The `System.Nullable` struct. */ class SystemNullableStruct extends SystemUnboundGenericStruct { SystemNullableStruct() {