Skip to content

Commit 45e416b

Browse files
committed
C#: Convert System.IO.Stream flow to CSV format.
1 parent dd1ae0b commit 45e416b

File tree

2 files changed

+23
-26
lines changed

2 files changed

+23
-26
lines changed

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

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,32 +1779,6 @@ library class SystemTextEncodingFlow extends LibraryTypeDataFlow, SystemTextEnco
17791779
}
17801780
}
17811781

1782-
/** Data flow for `System.IO.Stream`. */
1783-
class SystemIOStreamFlow extends LibraryTypeDataFlow, SystemIOStreamClass {
1784-
override predicate callableFlow(
1785-
CallableFlowSource source, CallableFlowSink sink, SourceDeclarationCallable c,
1786-
boolean preservesValue
1787-
) {
1788-
(
1789-
c = this.getAReadMethod().getAnOverrider*() and
1790-
c.getParameter(0).getType().(ArrayType).getElementType() instanceof ByteType and
1791-
sink = TCallableFlowSinkArg(0) and
1792-
source = TCallableFlowSourceQualifier()
1793-
or
1794-
c = this.getAWriteMethod().getAnOverrider*() and
1795-
c.getParameter(0).getType().(ArrayType).getElementType() instanceof ByteType and
1796-
source = TCallableFlowSourceArg(0) and
1797-
sink = TCallableFlowSinkQualifier()
1798-
or
1799-
c = any(Method m | m = this.getAMethod() and m.getName().matches("CopyTo%")).getAnOverrider*() and
1800-
c.getParameter(0).getType() instanceof SystemIOStreamClass and
1801-
source = TCallableFlowSourceQualifier() and
1802-
sink = TCallableFlowSinkArg(0)
1803-
) and
1804-
preservesValue = false
1805-
}
1806-
}
1807-
18081782
/** Data flow for `System.IO.Compression.DeflateStream`. */
18091783
class SystemIOCompressionDeflateStreamFlow extends LibraryTypeDataFlow,
18101784
SystemIOCompressionDeflateStream {

csharp/ql/lib/semmle/code/csharp/frameworks/system/IO.qll

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,29 @@ class SystemIOStreamClass extends SystemIOClass {
112112
}
113113
}
114114

115+
/** Data flow for `System.IO.Stream`. */
116+
private class SystemIOStreamFlowModelCsv extends SummaryModelCsv {
117+
override predicate row(string row) {
118+
row =
119+
[
120+
"System.IO;Stream;false;CopyTo;(System.IO.Stream);;Argument[-1];Argument[0];taint",
121+
"System.IO;Stream;false;CopyToAsync;(System.IO.Stream);;Argument[-1];Argument[0];taint",
122+
"System.IO;Stream;false;CopyToAsync;(System.IO.Stream,System.Int32);;Argument[-1];Argument[0];taint",
123+
"System.IO;Stream;false;CopyToAsync;(System.IO.Stream,System.Threading.CancellationToken);;Argument[-1];Argument[0];taint",
124+
"System.IO;Stream;false;ReadAsync;(System.Byte[],System.Int32,System.Int32);;Argument[-1];Argument[0];taint",
125+
"System.IO;Stream;false;WriteAsync;(System.Byte[],System.Int32,System.Int32);;Argument[0];Argument[-1];taint",
126+
"System.IO;Stream;true;BeginRead;(System.Byte[],System.Int32,System.Int32,System.AsyncCallback,System.Object);;Argument[-1];Argument[0];taint",
127+
"System.IO;Stream;true;BeginWrite;(System.Byte[],System.Int32,System.Int32,System.AsyncCallback,System.Object);;Argument[0];Argument[-1];taint",
128+
"System.IO;Stream;true;CopyTo;(System.IO.Stream,System.Int32);;Argument[-1];Argument[0];taint",
129+
"System.IO;Stream;true;CopyToAsync;(System.IO.Stream,System.Int32,System.Threading.CancellationToken);;Argument[-1];Argument[0];taint",
130+
"System.IO;Stream;true;Read;(System.Byte[],System.Int32,System.Int32);;Argument[-1];Argument[0];taint",
131+
"System.IO;Stream;true;ReadAsync;(System.Byte[],System.Int32,System.Int32,System.Threading.CancellationToken);;Argument[-1];Argument[0];taint",
132+
"System.IO;Stream;true;Write;(System.Byte[],System.Int32,System.Int32);;Argument[0];Argument[-1];taint",
133+
"System.IO;Stream;true;WriteAsync;(System.Byte[],System.Int32,System.Int32,System.Threading.CancellationToken);;Argument[0];Argument[-1];taint"
134+
]
135+
}
136+
}
137+
115138
/** The `System.IO.MemoryStream` class. */
116139
class SystemIOMemoryStreamClass extends SystemIOClass {
117140
SystemIOMemoryStreamClass() { this.hasName("MemoryStream") }

0 commit comments

Comments
 (0)