Skip to content

Commit 15b4b21

Browse files
committed
C#: Convert System.Nullable<> flow to CSV format.
1 parent bbab0e5 commit 15b4b21

File tree

2 files changed

+15
-43
lines changed

2 files changed

+15
-43
lines changed

csharp/ql/lib/semmle/code/csharp/dataflow/LibraryTypeDataFlow.qll

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -546,49 +546,6 @@ class SystemTextStringBuilderFlow extends LibraryTypeDataFlow, SystemTextStringB
546546
}
547547
}
548548

549-
/** Data flow for `System.Nullable<>`. */
550-
class SystemNullableFlow extends LibraryTypeDataFlow, SystemNullableStruct {
551-
override predicate callableFlow(
552-
CallableFlowSource source, AccessPath sourceAp, CallableFlowSink sink, AccessPath sinkAp,
553-
SourceDeclarationCallable c, boolean preservesValue
554-
) {
555-
preservesValue = true and
556-
c.(Constructor).getDeclaringType() = this and
557-
source = getFlowSourceArg(c, 0, sourceAp) and
558-
sourceAp = AccessPath::empty() and
559-
sink = TCallableFlowSinkReturn() and
560-
sinkAp = AccessPath::property(this.getValueProperty())
561-
or
562-
preservesValue = true and
563-
c = this.getAGetValueOrDefaultMethod() and
564-
source = TCallableFlowSourceQualifier() and
565-
sourceAp = AccessPath::property(this.getValueProperty()) and
566-
sink = TCallableFlowSinkReturn() and
567-
sinkAp = AccessPath::empty()
568-
or
569-
preservesValue = false and
570-
c = this.getHasValueProperty().getGetter() and
571-
source = TCallableFlowSourceQualifier() and
572-
sourceAp = AccessPath::property(this.getValueProperty()) and
573-
sink = TCallableFlowSinkReturn() and
574-
sinkAp = AccessPath::empty()
575-
or
576-
preservesValue = true and
577-
c = this.getAGetValueOrDefaultMethod() and
578-
source = getFlowSourceArg(c, 0, _) and
579-
sourceAp = AccessPath::empty() and
580-
sink = TCallableFlowSinkReturn() and
581-
sinkAp = AccessPath::empty()
582-
or
583-
preservesValue = false and
584-
c = this.getValueProperty().getGetter() and
585-
source = TCallableFlowSourceQualifier() and
586-
sourceAp = AccessPath::empty() and
587-
sink = TCallableFlowSinkReturn() and
588-
sinkAp = AccessPath::empty()
589-
}
590-
}
591-
592549
/** Data flow for `System.Collections.IEnumerable` (and sub types). */
593550
class IEnumerableFlow extends LibraryTypeDataFlow, RefType {
594551
IEnumerableFlow() { this.getABaseType*() instanceof SystemCollectionsIEnumerableInterface }

csharp/ql/lib/semmle/code/csharp/frameworks/System.qll

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,21 @@ class SystemNullableStruct extends SystemUnboundGenericStruct {
299299
}
300300
}
301301

302+
/** Data flow for `System.Nullable<>`. */
303+
private class SystemNullableFlowModelCsv extends SummaryModelCsv {
304+
override predicate row(string row) {
305+
row =
306+
[
307+
"System;Nullable<>;false;GetValueOrDefault;();;Property[System.Nullable<>.Value] of Argument[-1];ReturnValue;value",
308+
"System;Nullable<>;false;GetValueOrDefault;(T);;Argument[0];ReturnValue;value",
309+
"System;Nullable<>;false;GetValueOrDefault;(T);;Property[System.Nullable<>.Value] of Argument[-1];ReturnValue;value",
310+
"System;Nullable<>;false;Nullable;(T);;Argument[0];Property[System.Nullable<>.Value] of ReturnValue;value",
311+
"System;Nullable<>;false;get_HasValue;();;Property[System.Nullable<>.Value] of Argument[-1];ReturnValue;taint",
312+
"System;Nullable<>;false;get_Value;();;Argument[-1];ReturnValue;taint",
313+
]
314+
}
315+
}
316+
302317
/** The `System.NullReferenceException` class. */
303318
class SystemNullReferenceExceptionClass extends SystemClass {
304319
SystemNullReferenceExceptionClass() { this.hasName("NullReferenceException") }

0 commit comments

Comments
 (0)