Skip to content

Commit dd1ae0b

Browse files
committed
C#: Convert System.IO.MemoryStream flow to CSV format.
1 parent 85ff57b commit dd1ae0b

File tree

2 files changed

+14
-24
lines changed

2 files changed

+14
-24
lines changed

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

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

1782-
/** Data flow for `System.IO.MemoryStream`. */
1783-
library class SystemIOMemoryStreamFlow extends LibraryTypeDataFlow, SystemIOMemoryStreamClass {
1784-
override predicate callableFlow(
1785-
CallableFlowSource source, CallableFlowSink sink, SourceDeclarationCallable c,
1786-
boolean preservesValue
1787-
) {
1788-
(
1789-
this.constructorFlow(source, sink, c)
1790-
or
1791-
c = this.getToArrayMethod().getAnOverrider*() and
1792-
source = TCallableFlowSourceQualifier() and
1793-
sink = TCallableFlowSinkReturn()
1794-
) and
1795-
preservesValue = false
1796-
}
1797-
1798-
private predicate constructorFlow(CallableFlowSource source, CallableFlowSink sink, Constructor c) {
1799-
c = this.getAMember() and
1800-
c.getParameter(0).getType().(ArrayType).getElementType() instanceof ByteType and
1801-
source = TCallableFlowSourceArg(0) and
1802-
sink = TCallableFlowSinkReturn()
1803-
}
1804-
}
1805-
18061782
/** Data flow for `System.IO.Stream`. */
18071783
class SystemIOStreamFlow extends LibraryTypeDataFlow, SystemIOStreamClass {
18081784
override predicate callableFlow(

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,17 @@ class SystemIOMemoryStreamClass extends SystemIOClass {
122122
result.hasName("ToArray")
123123
}
124124
}
125+
126+
private class SystemIOMemoryStreamFlowModelCsv extends SummaryModelCsv {
127+
override predicate row(string row) {
128+
row =
129+
[
130+
"System.IO;MemoryStream;false;MemoryStream;(System.Byte[]);;Argument[0];ReturnValue;taint",
131+
"System.IO;MemoryStream;false;MemoryStream;(System.Byte[],System.Boolean);;Argument[0];ReturnValue;taint",
132+
"System.IO;MemoryStream;false;MemoryStream;(System.Byte[],System.Int32,System.Int32);;Argument[0];ReturnValue;taint",
133+
"System.IO;MemoryStream;false;MemoryStream;(System.Byte[],System.Int32,System.Int32,System.Boolean);;Argument[0];ReturnValue;taint",
134+
"System.IO;MemoryStream;false;MemoryStream;(System.Byte[],System.Int32,System.Int32,System.Boolean,System.Boolean);;Argument[0];ReturnValue;taint",
135+
"System.IO;MemoryStream;false;ToArray;();;Argument[-1];ReturnValue;taint"
136+
]
137+
}
138+
}

0 commit comments

Comments
 (0)