Skip to content

Commit bd31e7f

Browse files
authored
Merge pull request #20278 from michaelnebel/csharp/streamlinebulkmodels2
C#: Update MaD models to taint entire byte- and char collection.
2 parents bde143e + 7394a80 commit bd31e7f

File tree

12 files changed

+261
-257
lines changed

12 files changed

+261
-257
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* Models-as-data summaries for byte and char arrays and pointers now treat the entire collection as tainted, reflecting their common use as string alternatives.

csharp/ql/lib/ext/System.IO.model.yml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -77,25 +77,25 @@ extensions:
7777
- ["System.IO", "Path", False, "GetPathRoot", "(System.ReadOnlySpan<System.Char>)", "", "Argument[0].Element", "ReturnValue", "taint", "manual"]
7878
- ["System.IO", "Path", False, "GetPathRoot", "(System.String)", "", "Argument[0]", "ReturnValue", "taint", "manual"]
7979
- ["System.IO", "Path", False, "GetRelativePath", "(System.String,System.String)", "", "Argument[1]", "ReturnValue", "taint", "manual"]
80-
- ["System.IO", "Stream", True, "BeginRead", "(System.Byte[],System.Int32,System.Int32,System.AsyncCallback,System.Object)", "", "Argument[this]", "Argument[0].Element", "taint", "manual"]
80+
- ["System.IO", "Stream", True, "BeginRead", "(System.Byte[],System.Int32,System.Int32,System.AsyncCallback,System.Object)", "", "Argument[this]", "Argument[0]", "taint", "manual"]
8181
- ["System.IO", "Stream", True, "BeginWrite", "(System.Byte[],System.Int32,System.Int32,System.AsyncCallback,System.Object)", "", "Argument[0].Element", "Argument[this]", "taint", "manual"]
8282
- ["System.IO", "Stream", False, "CopyTo", "(System.IO.Stream)", "", "Argument[this]", "Argument[0]", "taint", "manual"]
8383
- ["System.IO", "Stream", True, "CopyTo", "(System.IO.Stream,System.Int32)", "", "Argument[this]", "Argument[0]", "taint", "manual"]
8484
- ["System.IO", "Stream", False, "CopyToAsync", "(System.IO.Stream)", "", "Argument[this]", "Argument[0]", "taint", "manual"]
8585
- ["System.IO", "Stream", False, "CopyToAsync", "(System.IO.Stream,System.Int32)", "", "Argument[this]", "Argument[0]", "taint", "manual"]
8686
- ["System.IO", "Stream", True, "CopyToAsync", "(System.IO.Stream,System.Int32,System.Threading.CancellationToken)", "", "Argument[this]", "Argument[0]", "taint", "manual"]
8787
- ["System.IO", "Stream", False, "CopyToAsync", "(System.IO.Stream,System.Threading.CancellationToken)", "", "Argument[this]", "Argument[0]", "taint", "manual"]
88-
- ["System.IO", "Stream", True, "Read", "(System.Byte[],System.Int32,System.Int32)", "", "Argument[this]", "Argument[0].Element", "taint", "manual"]
89-
- ["System.IO", "Stream", True, "Read", "(System.Span<System.Byte>)", "", "Argument[this]", "Argument[0].Element", "taint", "manual"]
90-
- ["System.IO", "Stream", False, "ReadAsync", "(System.Byte[],System.Int32,System.Int32)", "", "Argument[this]", "Argument[0].Element", "taint", "manual"]
91-
- ["System.IO", "Stream", True, "ReadAsync", "(System.Byte[],System.Int32,System.Int32,System.Threading.CancellationToken)", "", "Argument[this]", "Argument[0].Element", "taint", "manual"]
88+
- ["System.IO", "Stream", True, "Read", "(System.Byte[],System.Int32,System.Int32)", "", "Argument[this]", "Argument[0]", "taint", "manual"]
89+
- ["System.IO", "Stream", True, "Read", "(System.Span<System.Byte>)", "", "Argument[this]", "Argument[0]", "taint", "manual"]
90+
- ["System.IO", "Stream", False, "ReadAsync", "(System.Byte[],System.Int32,System.Int32)", "", "Argument[this]", "Argument[0]", "taint", "manual"]
91+
- ["System.IO", "Stream", True, "ReadAsync", "(System.Byte[],System.Int32,System.Int32,System.Threading.CancellationToken)", "", "Argument[this]", "Argument[0]", "taint", "manual"]
9292
# Post-update nodes for `Memory<T>` are currently unsupported. This model is provided for completeness
93-
- ["System.IO", "Stream", True, "ReadAsync", "(System.Memory<System.Byte>,System.Threading.CancellationToken)", "", "Argument[this]", "Argument[0].Element", "taint", "manual"]
94-
- ["System.IO", "Stream", True, "ReadAtLeast", "(System.Span<System.Byte>,System.Int32,System.Boolean)", "", "Argument[this]", "Argument[0].Element", "taint", "manual"]
93+
- ["System.IO", "Stream", True, "ReadAsync", "(System.Memory<System.Byte>,System.Threading.CancellationToken)", "", "Argument[this]", "Argument[0]", "taint", "manual"]
94+
- ["System.IO", "Stream", True, "ReadAtLeast", "(System.Span<System.Byte>,System.Int32,System.Boolean)", "", "Argument[this]", "Argument[0]", "taint", "manual"]
9595
# Post-update nodes for `Memory<T>` are currently unsupported. This model is provided for completeness
9696
- ["System.IO", "Stream", True, "ReadAtLeastAsync", "(System.Memory<System.Byte>,System.Int32,System.Boolean,System.Threading.CancellationToken)", "", "Argument[this]", "Argument[0]", "taint", "manual"]
97-
- ["System.IO", "Stream", True, "ReadExactly", "(System.Span<System.Byte>)", "", "Argument[this]", "Argument[0].Element", "taint", "manual"]
98-
- ["System.IO", "Stream", True, "ReadExactly", "(System.Byte[],System.Int32,System.Int32)", "", "Argument[this]", "Argument[0].Element", "taint", "manual"]
97+
- ["System.IO", "Stream", True, "ReadExactly", "(System.Span<System.Byte>)", "", "Argument[this]", "Argument[0]", "taint", "manual"]
98+
- ["System.IO", "Stream", True, "ReadExactly", "(System.Byte[],System.Int32,System.Int32)", "", "Argument[this]", "Argument[0]", "taint", "manual"]
9999
- ["System.IO", "Stream", True, "Write", "(System.Byte[],System.Int32,System.Int32)", "", "Argument[0].Element", "Argument[this]", "taint", "manual"]
100100
- ["System.IO", "Stream", True, "Write", "(System.ReadOnlySpan<System.Byte>)", "", "Argument[0].Element", "Argument[this]", "taint", "manual"]
101101
- ["System.IO", "Stream", False, "WriteAsync", "(System.Byte[],System.Int32,System.Int32)", "", "Argument[0].Element", "Argument[this]", "taint", "manual"]
@@ -128,16 +128,16 @@ extensions:
128128
- ["System.IO", "StringWriter", True, "WriteLineAsync", "(System.String)", "", "Argument[0]", "Argument[this]", "taint", "manual"]
129129
- ["System.IO", "StringWriter", True, "WriteLineAsync", "(System.Text.StringBuilder,System.Threading.CancellationToken)", "", "Argument[0]", "Argument[this]", "taint", "manual"]
130130
- ["System.IO", "TextReader", True, "Read", "()", "", "Argument[this]", "ReturnValue", "taint", "manual"]
131-
- ["System.IO", "TextReader", True, "Read", "(System.Char[],System.Int32,System.Int32)", "", "Argument[this]", "Argument[0].Element", "taint", "manual"]
132-
- ["System.IO", "TextReader", True, "Read", "(System.Span<System.Char>)", "", "Argument[this]", "Argument[0].Element", "taint", "manual"]
133-
- ["System.IO", "TextReader", True, "ReadAsync", "(System.Char[],System.Int32,System.Int32)", "", "Argument[this]", "Argument[0].Element", "taint", "manual"]
131+
- ["System.IO", "TextReader", True, "Read", "(System.Char[],System.Int32,System.Int32)", "", "Argument[this]", "Argument[0]", "taint", "manual"]
132+
- ["System.IO", "TextReader", True, "Read", "(System.Span<System.Char>)", "", "Argument[this]", "Argument[0]", "taint", "manual"]
133+
- ["System.IO", "TextReader", True, "ReadAsync", "(System.Char[],System.Int32,System.Int32)", "", "Argument[this]", "Argument[0]", "taint", "manual"]
134134
# Post-update nodes for `Memory<T>` are currently unsupported. This model is provided for completeness
135-
- ["System.IO", "TextReader", True, "ReadAsync", "(System.Memory<System.Char>,System.Threading.CancellationToken)", "", "Argument[this]", "Argument[0].Element", "taint", "manual"]
136-
- ["System.IO", "TextReader", True, "ReadBlock", "(System.Char[],System.Int32,System.Int32)", "", "Argument[this]", "Argument[0].Element", "taint", "manual"]
137-
- ["System.IO", "TextReader", True, "ReadBlock", "(System.Span<System.Char>)", "", "Argument[this]", "Argument[0].Element", "taint", "manual"]
138-
- ["System.IO", "TextReader", True, "ReadBlockAsync", "(System.Char[],System.Int32,System.Int32)", "", "Argument[this]", "Argument[0].Element", "taint", "manual"]
135+
- ["System.IO", "TextReader", True, "ReadAsync", "(System.Memory<System.Char>,System.Threading.CancellationToken)", "", "Argument[this]", "Argument[0]", "taint", "manual"]
136+
- ["System.IO", "TextReader", True, "ReadBlock", "(System.Char[],System.Int32,System.Int32)", "", "Argument[this]", "Argument[0]", "taint", "manual"]
137+
- ["System.IO", "TextReader", True, "ReadBlock", "(System.Span<System.Char>)", "", "Argument[this]", "Argument[0]", "taint", "manual"]
138+
- ["System.IO", "TextReader", True, "ReadBlockAsync", "(System.Char[],System.Int32,System.Int32)", "", "Argument[this]", "Argument[0]", "taint", "manual"]
139139
# Post-update nodes for `Memory<T>` are currently unsupported. This model is provided for completeness
140-
- ["System.IO", "TextReader", True, "ReadBlockAsync", "(System.Memory<System.Char>,System.Threading.CancellationToken)", "", "Argument[this]", "Argument[0].Element", "taint", "manual"]
140+
- ["System.IO", "TextReader", True, "ReadBlockAsync", "(System.Memory<System.Char>,System.Threading.CancellationToken)", "", "Argument[this]", "Argument[0]", "taint", "manual"]
141141
- ["System.IO", "TextReader", True, "ReadLine", "()", "", "Argument[this]", "ReturnValue", "taint", "manual"]
142142
- ["System.IO", "TextReader", True, "ReadLineAsync", "()", "", "Argument[this]", "ReturnValue", "taint", "manual"]
143143
- ["System.IO", "TextReader", True, "ReadToEnd", "()", "", "Argument[this]", "ReturnValue", "taint", "manual"]

csharp/ql/lib/ext/System.model.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ extensions:
3939
- ["System", "Convert", False, "ChangeType", "(System.Object,System.Type,System.IFormatProvider)", "", "Argument[0]", "ReturnValue", "taint", "manual"]
4040
- ["System", "Convert", False, "ChangeType", "(System.Object,System.TypeCode)", "", "Argument[0]", "ReturnValue", "taint", "manual"]
4141
- ["System", "Convert", False, "ChangeType", "(System.Object,System.TypeCode,System.IFormatProvider)", "", "Argument[0]", "ReturnValue", "taint", "manual"]
42-
- ["System", "Convert", False, "FromBase64CharArray", "(System.Char[],System.Int32,System.Int32)", "", "Argument[0].Element", "ReturnValue.Element", "taint", "manual"]
43-
- ["System", "Convert", False, "FromBase64String", "(System.String)", "", "Argument[0]", "ReturnValue.Element", "taint", "manual"]
44-
- ["System", "Convert", False, "FromHexString", "(System.ReadOnlySpan<System.Char>)", "", "Argument[0].Element", "ReturnValue.Element", "taint", "manual"]
45-
- ["System", "Convert", False, "FromHexString", "(System.String)", "", "Argument[0]", "ReturnValue.Element", "taint", "manual"]
42+
- ["System", "Convert", False, "FromBase64CharArray", "(System.Char[],System.Int32,System.Int32)", "", "Argument[0].Element", "ReturnValue", "taint", "manual"]
43+
- ["System", "Convert", False, "FromBase64String", "(System.String)", "", "Argument[0]", "ReturnValue", "taint", "manual"]
44+
- ["System", "Convert", False, "FromHexString", "(System.ReadOnlySpan<System.Char>)", "", "Argument[0].Element", "ReturnValue", "taint", "manual"]
45+
- ["System", "Convert", False, "FromHexString", "(System.String)", "", "Argument[0]", "ReturnValue", "taint", "manual"]
4646
- ["System", "Convert", False, "GetTypeCode", "(System.Object)", "", "Argument[0]", "ReturnValue", "taint", "manual"]
4747
- ["System", "Convert", False, "IsDBNull", "(System.Object)", "", "Argument[0]", "ReturnValue", "taint", "manual"]
48-
- ["System", "Convert", False, "ToBase64CharArray", "(System.Byte[],System.Int32,System.Int32,System.Char[],System.Int32)", "", "Argument[0].Element", "Argument[3].Element", "taint", "manual"]
48+
- ["System", "Convert", False, "ToBase64CharArray", "(System.Byte[],System.Int32,System.Int32,System.Char[],System.Int32)", "", "Argument[0].Element", "Argument[3]", "taint", "manual"]
4949
- ["System", "Convert", False, "ToBase64CharArray", "(System.Byte[],System.Int32,System.Int32,System.Char[],System.Int32)", "", "Argument[0].Element", "ReturnValue", "taint", "manual"]
50-
- ["System", "Convert", False, "ToBase64CharArray", "(System.Byte[],System.Int32,System.Int32,System.Char[],System.Int32,System.Base64FormattingOptions)", "", "Argument[0].Element", "Argument[3].Element", "taint", "manual"]
50+
- ["System", "Convert", False, "ToBase64CharArray", "(System.Byte[],System.Int32,System.Int32,System.Char[],System.Int32,System.Base64FormattingOptions)", "", "Argument[0].Element", "Argument[3]", "taint", "manual"]
5151
- ["System", "Convert", False, "ToBase64CharArray", "(System.Byte[],System.Int32,System.Int32,System.Char[],System.Int32,System.Base64FormattingOptions)", "", "Argument[0].Element", "ReturnValue", "taint", "manual"]
5252
- ["System", "Convert", False, "ToBase64String", "(System.Byte[])", "", "Argument[0].Element", "ReturnValue", "taint", "manual"]
5353
- ["System", "Convert", False, "ToBase64String", "(System.Byte[],System.Base64FormattingOptions)", "", "Argument[0].Element", "ReturnValue", "taint", "manual"]
@@ -353,13 +353,13 @@ extensions:
353353
- ["System", "Convert", False, "ToUInt64", "(System.UInt16)", "", "Argument[0]", "ReturnValue", "taint", "manual"]
354354
- ["System", "Convert", False, "ToUInt64", "(System.UInt32)", "", "Argument[0]", "ReturnValue", "taint", "manual"]
355355
- ["System", "Convert", False, "ToUInt64", "(System.UInt64)", "", "Argument[0]", "ReturnValue", "taint", "manual"]
356-
- ["System", "Convert", False, "TryFromBase64Chars", "(System.ReadOnlySpan<System.Char>,System.Span<System.Byte>,System.Int32)", "", "Argument[0].Element", "Argument[1].Element", "taint", "manual"]
356+
- ["System", "Convert", False, "TryFromBase64Chars", "(System.ReadOnlySpan<System.Char>,System.Span<System.Byte>,System.Int32)", "", "Argument[0].Element", "Argument[1]", "taint", "manual"]
357357
- ["System", "Convert", False, "TryFromBase64Chars", "(System.ReadOnlySpan<System.Char>,System.Span<System.Byte>,System.Int32)", "", "Argument[0].Element", "Argument[2]", "taint", "manual"]
358358
- ["System", "Convert", False, "TryFromBase64Chars", "(System.ReadOnlySpan<System.Char>,System.Span<System.Byte>,System.Int32)", "", "Argument[0].Element", "ReturnValue", "taint", "manual"]
359-
- ["System", "Convert", False, "TryFromBase64String", "(System.String,System.Span<System.Byte>,System.Int32)", "", "Argument[0]", "Argument[1].Element", "taint", "manual"]
359+
- ["System", "Convert", False, "TryFromBase64String", "(System.String,System.Span<System.Byte>,System.Int32)", "", "Argument[0]", "Argument[1]", "taint", "manual"]
360360
- ["System", "Convert", False, "TryFromBase64String", "(System.String,System.Span<System.Byte>,System.Int32)", "", "Argument[0]", "Argument[2]", "taint", "manual"]
361361
- ["System", "Convert", False, "TryFromBase64String", "(System.String,System.Span<System.Byte>,System.Int32)", "", "Argument[0]", "ReturnValue", "taint", "manual"]
362-
- ["System", "Convert", False, "TryToBase64Chars", "(System.ReadOnlySpan<System.Byte>,System.Span<System.Char>,System.Int32,System.Base64FormattingOptions)", "", "Argument[0].Element", "Argument[1].Element", "taint", "manual"]
362+
- ["System", "Convert", False, "TryToBase64Chars", "(System.ReadOnlySpan<System.Byte>,System.Span<System.Char>,System.Int32,System.Base64FormattingOptions)", "", "Argument[0].Element", "Argument[1]", "taint", "manual"]
363363
- ["System", "Convert", False, "TryToBase64Chars", "(System.ReadOnlySpan<System.Byte>,System.Span<System.Char>,System.Int32,System.Base64FormattingOptions)", "", "Argument[0].Element", "Argument[2]", "taint", "manual"]
364364
- ["System", "Convert", False, "TryToBase64Chars", "(System.ReadOnlySpan<System.Byte>,System.Span<System.Char>,System.Int32,System.Base64FormattingOptions)", "", "Argument[0].Element", "ReturnValue", "taint", "manual"]
365365
- ["System", "Int32", False, "Parse", "(System.ReadOnlySpan<System.Char>,System.Globalization.NumberStyles,System.IFormatProvider)", "", "Argument[0].Element", "ReturnValue", "taint", "manual"]

0 commit comments

Comments
 (0)