Skip to content

Commit 0946ae2

Browse files
committed
Fix review findings
1 parent 3b58569 commit 0946ae2

File tree

4 files changed

+27
-20
lines changed

4 files changed

+27
-20
lines changed

csharp/ql/src/semmle/code/csharp/dataflow/ExternalFlow.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ private import internal.FlowSummaryImplSpecific
8686
private module Frameworks {
8787
private import semmle.code.csharp.security.dataflow.flowsources.Local
8888
private import semmle.code.csharp.security.dataflow.flowsinks.Html
89-
private import semmle.code.csharp.dataflow.LibraryTypeDataFlow
89+
private import semmle.code.csharp.frameworks.System
9090
private import semmle.code.csharp.security.dataflow.XSS
9191
}
9292

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ private import semmle.code.csharp.dataflow.internal.DelegateDataFlow
2323
private import semmle.code.csharp.frameworks.EntityFramework
2424
private import semmle.code.csharp.frameworks.JsonNET
2525
private import FlowSummary
26-
private import semmle.code.csharp.dataflow.ExternalFlow
2726

2827
private newtype TAccessPath =
2928
TNilAccessPath() or
@@ -500,21 +499,6 @@ private module FrameworkDataFlowAdaptor {
500499
}
501500
}
502501

503-
/** Data flow for `System.Int32`. */
504-
private class SystemInt32FlowModelCsv extends SummaryModelCsv {
505-
override predicate row(string row) {
506-
row =
507-
[
508-
"System;Int32;false;Parse;;;Argument[0];ReturnValue;taint",
509-
"System;Int32;false;TryParse;;;Argument[0];ReturnValue;taint",
510-
"System;Int32;false;TryParse;(System.String,System.Int32);;Argument[0];Argument[1];taint",
511-
"System;Int32;false;TryParse;(System.ReadOnlySpan<System.Char>,System.Int32);;Element of Argument[0];Argument[1];taint",
512-
"System;Int32;false;TryParse;(System.String,System.Globalization.NumberStyles,System.IFormatProvider,System.Int32);;Argument[0];Argument[3];taint",
513-
"System;Int32;false;TryParse;(System.ReadOnlySpan<System.Char>,System.Globalization.NumberStyles,System.IFormatProvider,System.Int32);;Element of Argument[0];Argument[3];taint"
514-
]
515-
}
516-
}
517-
518502
/** Data flow for `System.Boolean`. */
519503
class SystemBooleanFlow extends LibraryTypeDataFlow, SystemBooleanStruct {
520504
override predicate callableFlow(

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import csharp
44
private import system.Reflection
5+
private import semmle.code.csharp.dataflow.ExternalFlow
56

67
/** The `System` namespace. */
78
class SystemNamespace extends Namespace {
@@ -200,6 +201,28 @@ class SystemInt32Struct extends IntType {
200201
}
201202
}
202203

204+
/** Data flow for `System.Int32`. */
205+
private class SystemInt32FlowModelCsv extends SummaryModelCsv {
206+
override predicate row(string row) {
207+
row =
208+
[
209+
"System;Int32;false;Parse;(System.String);;Argument[0];ReturnValue;taint",
210+
"System;Int32;false;Parse;(System.String,System.IFormatProvider);;Argument[0];ReturnValue;taint",
211+
"System;Int32;false;Parse;(System.String,System.Globalization.NumberStyles);;Argument[0];ReturnValue;taint",
212+
"System;Int32;false;Parse;(System.String,System.Globalization.NumberStyles,System.IFormatProvider);;Argument[0];ReturnValue;taint",
213+
"System;Int32;false;Parse;(System.ReadOnlySpan<System.Char>,System.Globalization.NumberStyles,System.IFormatProvider);;Element of Argument[0];ReturnValue;taint",
214+
"System;Int32;false;TryParse;(System.String,System.Int32);;Argument[0];ReturnValue;taint",
215+
"System;Int32;false;TryParse;(System.String,System.Int32);;Argument[0];Argument[1];taint",
216+
"System;Int32;false;TryParse;(System.ReadOnlySpan<System.Char>,System.Int32);;Element of Argument[0];ReturnValue;taint",
217+
"System;Int32;false;TryParse;(System.ReadOnlySpan<System.Char>,System.Int32);;Element of Argument[0];Argument[1];taint",
218+
"System;Int32;false;TryParse;(System.String,System.Globalization.NumberStyles,System.IFormatProvider,System.Int32);;Argument[0];ReturnValue;taint",
219+
"System;Int32;false;TryParse;(System.String,System.Globalization.NumberStyles,System.IFormatProvider,System.Int32);;Argument[0];Argument[3];taint",
220+
"System;Int32;false;TryParse;(System.ReadOnlySpan<System.Char>,System.Globalization.NumberStyles,System.IFormatProvider,System.Int32);;Element of Argument[0];ReturnValue;taint",
221+
"System;Int32;false;TryParse;(System.ReadOnlySpan<System.Char>,System.Globalization.NumberStyles,System.IFormatProvider,System.Int32);;Element of Argument[0];Argument[3];taint"
222+
]
223+
}
224+
}
225+
203226
/** The `System.InvalidCastException` class. */
204227
class SystemInvalidCastExceptionClass extends SystemClass {
205228
SystemInvalidCastExceptionClass() { this.hasName("InvalidCastException") }

csharp/ql/test/library-tests/dataflow/library/FlowSummaries.expected

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,15 +1217,15 @@
12171217
| System.IO.UnmanagedMemoryStreamWrapper.ToArray() | argument -1 -> return (normal) | false |
12181218
| System.IO.UnmanagedMemoryStreamWrapper.Write(Byte[], int, int) | argument 0 -> argument -1 | false |
12191219
| System.IO.UnmanagedMemoryStreamWrapper.WriteAsync(Byte[], int, int, CancellationToken) | argument 0 -> argument -1 | false |
1220-
| System.Int32.Parse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider) | argument 0 -> return (normal) | false |
1220+
| System.Int32.Parse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider) | element of argument 0 -> return (normal) | false |
12211221
| System.Int32.Parse(string) | argument 0 -> return (normal) | false |
12221222
| System.Int32.Parse(string, IFormatProvider) | argument 0 -> return (normal) | false |
12231223
| System.Int32.Parse(string, NumberStyles) | argument 0 -> return (normal) | false |
12241224
| System.Int32.Parse(string, NumberStyles, IFormatProvider) | argument 0 -> return (normal) | false |
1225-
| System.Int32.TryParse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider, out int) | argument 0 -> return (normal) | false |
12261225
| System.Int32.TryParse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider, out int) | element of argument 0 -> argument 3 | false |
1227-
| System.Int32.TryParse(ReadOnlySpan<Char>, out int) | argument 0 -> return (normal) | false |
1226+
| System.Int32.TryParse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider, out int) | element of argument 0 -> return (normal) | false |
12281227
| System.Int32.TryParse(ReadOnlySpan<Char>, out int) | element of argument 0 -> argument 1 | false |
1228+
| System.Int32.TryParse(ReadOnlySpan<Char>, out int) | element of argument 0 -> return (normal) | false |
12291229
| System.Int32.TryParse(string, NumberStyles, IFormatProvider, out int) | argument 0 -> argument 3 | false |
12301230
| System.Int32.TryParse(string, NumberStyles, IFormatProvider, out int) | argument 0 -> return (normal) | false |
12311231
| System.Int32.TryParse(string, out int) | argument 0 -> argument 1 | false |

0 commit comments

Comments
 (0)