Skip to content

Commit 9881fdf

Browse files
Convert sources to MaD
1 parent 17cfd48 commit 9881fdf

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ extensions:
44
extensible: sourceModel
55
data:
66
- ["System.IO", "FileStream", False, "FileStream", "", "", "Argument[this]", "file", "manual"]
7+
- ["System.IO", "FileStream", False, "FileStream", "", "", "Argument[this]", "file-write", "manual"]
8+
- ["System.IO", "StreamWriter", False, "StreamWriter", "(System.String)", "", "Argument[this]", "file-write", "manual"]
9+
- ["System.IO", "StreamWriter", False, "StreamWriter", "(System.String,System.Boolean)", "", "Argument[this]", "file-write", "manual"]
10+
- ["System.IO", "StreamWriter", False, "StreamWriter", "(System.String,System.Boolean,System.Text.Encoding)", "", "Argument[this]", "file-write", "manual"]
11+
- ["System.IO", "StreamWriter", False, "StreamWriter", "(System.String,System.Boolean,System.Text.Encoding,System.Int32)", "", "Argument[this]", "file-write", "manual"]
12+
- ["System.IO", "StreamWriter", False, "StreamWriter", "(System.String,System.Text.Encoding,System.IO.FileStreamOptions)", "", "Argument[this]", "file-write", "manual"]
13+
- ["System.IO", "StreamWriter", False, "StreamWriter", "(System.String,System.IO.FileStreamOptions)", "", "Argument[this]", "file-write", "manual"]
14+
- ["System.IO", "File", False, "Open", "", "", "ReturnValue", "file-write", "manual"]
15+
- ["System.IO", "File", False, "OpenWrite", "", "", "ReturnValue", "file-write", "manual"]
16+
- ["System.IO", "File", False, "Create", "", "", "ReturnValue", "file-write", "manual"]
717
- addsTo:
818
pack: codeql/csharp-all
919
extensible: summaryModel

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ module ModelValidation {
212212
)
213213
or
214214
exists(string kind | sourceModel(_, _, _, _, _, _, _, kind, _) |
215-
not kind = ["local", "remote", "file"] and
215+
not kind = ["local", "remote", "file", "file-write"] and
216216
result = "Invalid kind \"" + kind + "\" in source model."
217217
)
218218
}

csharp/ql/lib/semmle/code/csharp/security/dataflow/flowsinks/ExternalLocationSink.qll

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,7 @@ private predicate isFileWriteCall(Expr stream, Expr data) {
8383
}
8484

8585
private module LocalFileOutputStreamConfig implements DataFlow::ConfigSig {
86-
predicate isSource(DataFlow::Node src) {
87-
exists(MethodCall mc | mc = src.asExpr() |
88-
mc.getTarget().hasQualifiedName("System.IO", "File", ["Open", "Create", "OpenWrite"])
89-
or
90-
mc.getTarget()
91-
.hasQualifiedName("System.IO", "FileInfo",
92-
["AppendText", "Create", "CreateText", "Open", "OpenText", "OpenWrite"])
93-
)
94-
or
95-
exists(ObjectCreation oc | oc = src.asExpr() |
96-
oc.getObjectType() instanceof SystemIOStreamWriterClass and
97-
oc.getArgument(0).getType() instanceof StringType
98-
)
99-
}
86+
predicate isSource(DataFlow::Node src) { sourceNode(src, "file-write") }
10087

10188
predicate isSink(DataFlow::Node sink) { isFileWriteCall(sink.asExpr(), _) }
10289

0 commit comments

Comments
 (0)