mirror of
https://github.com/github/codeql.git
synced 2026-05-04 13:15:21 +02:00
C#: Consider FileStreams StoredFlowSources and propagate taint via StreamReader.
This commit is contained in:
@@ -383,7 +383,7 @@ module CsvValidation {
|
||||
or
|
||||
exists(string row, string kind | sourceModel(row) |
|
||||
kind = row.splitAt(";", 7) and
|
||||
not kind = "local" and
|
||||
not kind = ["local", "file"] and
|
||||
msg = "Invalid kind \"" + kind + "\" in source model."
|
||||
)
|
||||
}
|
||||
|
||||
@@ -179,6 +179,7 @@ class SystemIOMemoryStreamClass extends SystemIOClass {
|
||||
}
|
||||
}
|
||||
|
||||
/** Data flow for `System.IO.MemoryStream`. */
|
||||
private class SystemIOMemoryStreamFlowModelCsv extends SummaryModelCsv {
|
||||
override predicate row(string row) {
|
||||
row =
|
||||
@@ -192,3 +193,17 @@ private class SystemIOMemoryStreamFlowModelCsv extends SummaryModelCsv {
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
/** Sources for `System.IO.FileStream`. */
|
||||
private class SystemIOFileStreamSourceModelCsv extends SourceModelCsv {
|
||||
override predicate row(string row) {
|
||||
row = "System.IO;FileStream;false;FileStream;;;Argument[Qualifier];file;manual"
|
||||
}
|
||||
}
|
||||
|
||||
/** Data flow for `System.IO.StreamReader`. */
|
||||
private class SystemIOStreamSummaryModelCsv extends SummaryModelCsv {
|
||||
override predicate row(string row) {
|
||||
row = "System.IO;StreamReader;false;StreamReader;;;Argument[0];Argument[Qualifier];taint;manual"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
import csharp
|
||||
private import semmle.code.csharp.dataflow.ExternalFlow
|
||||
private import semmle.code.csharp.frameworks.system.data.Common
|
||||
private import semmle.code.csharp.frameworks.system.data.Entity
|
||||
private import semmle.code.csharp.frameworks.EntityFramework
|
||||
@@ -55,3 +56,8 @@ class ORMMappedProperty extends StoredFlowSource {
|
||||
this instanceof NHibernate::StoredFlowSource
|
||||
}
|
||||
}
|
||||
|
||||
/** A file stream source is considered a stored flow source. */
|
||||
class FileStreamStoredFlowSource extends StoredFlowSource {
|
||||
FileStreamStoredFlowSource() { sourceNode(this, "file") }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user