Skip to content

Commit 45568d5

Browse files
committed
C#: Convert System.Console.Read* local flow source to CSV
1 parent 9606816 commit 45568d5

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
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
@@ -84,7 +84,7 @@ private import internal.FlowSummaryImplSpecific
8484
* ensuring that they are visible to the taint tracking / data flow library.
8585
*/
8686
private module Frameworks {
87-
// TODO
87+
private import semmle.code.csharp.security.dataflow.flowsources.Local
8888
}
8989

9090
/**

csharp/ql/src/semmle/code/csharp/security/dataflow/flowsources/Local.qll

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,20 @@
44

55
import csharp
66
private import semmle.code.csharp.frameworks.system.windows.Forms
7+
private import semmle.code.csharp.dataflow.ExternalFlow
78

89
/** A data flow source of local data. */
910
abstract class LocalFlowSource extends DataFlow::Node {
1011
/** Gets a string that describes the type of this local flow source. */
1112
abstract string getSourceType();
1213
}
1314

15+
private class ExternalLocalFlowSource extends LocalFlowSource {
16+
ExternalLocalFlowSource() { sourceNode(this, "local") }
17+
18+
override string getSourceType() { result = "external" }
19+
}
20+
1421
/** A data flow source of local user input. */
1522
abstract class LocalUserInputSource extends LocalFlowSource { }
1623

@@ -22,13 +29,13 @@ class TextFieldSource extends LocalUserInputSource {
2229
}
2330

2431
/** A call to any `System.Console.Read*` method. */
25-
class SystemConsoleReadSource extends LocalUserInputSource {
26-
SystemConsoleReadSource() {
27-
this.asExpr() =
28-
any(MethodCall call |
29-
call.getTarget().hasQualifiedName("System.Console", ["ReadLine", "Read", "ReadKey"])
30-
)
32+
private class SystemConsoleReadSourceModelCsv extends SourceModelCsv {
33+
override predicate row(string row) {
34+
row =
35+
[
36+
"System;Console;false;ReadLine;;;ReturnValue;local",
37+
"System;Console;false;Read;;;ReturnValue;local",
38+
"System;Console;false;ReadKey;;;ReturnValue;local"
39+
]
3140
}
32-
33-
override string getSourceType() { result = "System.Console input" }
3441
}

0 commit comments

Comments
 (0)