Skip to content

Commit 16bcb4e

Browse files
committed
C#: Convert System.IO.Path flow to CSV format.
1 parent ca5c692 commit 16bcb4e

File tree

2 files changed

+32
-25
lines changed

2 files changed

+32
-25
lines changed

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

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1840,31 +1840,6 @@ class SystemXmlXmlNamedNodeMapFlow extends LibraryTypeDataFlow, SystemXmlXmlName
18401840
}
18411841
}
18421842

1843-
/** Data flow for `System.IO.Path`. */
1844-
class SystemIOPathFlow extends LibraryTypeDataFlow, SystemIOPathClass {
1845-
override predicate callableFlow(
1846-
CallableFlowSource source, AccessPath sourceAp, CallableFlowSink sink, AccessPath sinkAp,
1847-
SourceDeclarationCallable c, boolean preservesValue
1848-
) {
1849-
c = this.getAMethod("Combine") and
1850-
source = getFlowSourceArg(c, _, sourceAp) and
1851-
sink = TCallableFlowSinkReturn() and
1852-
sinkAp = AccessPath::empty() and
1853-
preservesValue = false
1854-
or
1855-
exists(Parameter p |
1856-
c = this.getAMethod() and
1857-
c.getName().matches("Get%") and
1858-
p = c.getAParameter() and
1859-
p.hasName("path") and
1860-
source = getFlowSourceArg(c, p.getPosition(), sourceAp) and
1861-
sink = TCallableFlowSinkReturn() and
1862-
sinkAp = AccessPath::empty() and
1863-
preservesValue = false
1864-
)
1865-
}
1866-
}
1867-
18681843
/**
18691844
* Custom flow through `StringValues` library class.
18701845
*/

csharp/ql/lib/semmle/code/csharp/frameworks/system/IO.qll

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,38 @@ class SystemIOPathClass extends SystemIOClass {
4242
SystemIOPathClass() { this.hasName("Path") }
4343
}
4444

45+
/** Data flow for `System.IO.Path`. */
46+
private class SystemIOPathFlowModelCsv extends SummaryModelCsv {
47+
override predicate row(string row) {
48+
row =
49+
[
50+
"System.IO;Path;false;Combine;(System.String,System.String);;Argument[0];ReturnValue;taint",
51+
"System.IO;Path;false;Combine;(System.String,System.String);;Argument[1];ReturnValue;taint",
52+
"System.IO;Path;false;Combine;(System.String,System.String,System.String);;Argument[0];ReturnValue;taint",
53+
"System.IO;Path;false;Combine;(System.String,System.String,System.String);;Argument[1];ReturnValue;taint",
54+
"System.IO;Path;false;Combine;(System.String,System.String,System.String);;Argument[2];ReturnValue;taint",
55+
"System.IO;Path;false;Combine;(System.String,System.String,System.String,System.String);;Argument[0];ReturnValue;taint",
56+
"System.IO;Path;false;Combine;(System.String,System.String,System.String,System.String);;Argument[1];ReturnValue;taint",
57+
"System.IO;Path;false;Combine;(System.String,System.String,System.String,System.String);;Argument[2];ReturnValue;taint",
58+
"System.IO;Path;false;Combine;(System.String,System.String,System.String,System.String);;Argument[3];ReturnValue;taint",
59+
"System.IO;Path;false;Combine;(System.String[]);;Element of Argument[0];ReturnValue;taint",
60+
"System.IO;Path;false;GetDirectoryName;(System.ReadOnlySpan<System.Char>);;Argument[0];ReturnValue;taint",
61+
"System.IO;Path;false;GetDirectoryName;(System.String);;Argument[0];ReturnValue;taint",
62+
"System.IO;Path;false;GetExtension;(System.ReadOnlySpan<System.Char>);;Argument[0];ReturnValue;taint",
63+
"System.IO;Path;false;GetExtension;(System.String);;Argument[0];ReturnValue;taint",
64+
"System.IO;Path;false;GetFileName;(System.ReadOnlySpan<System.Char>);;Argument[0];ReturnValue;taint",
65+
"System.IO;Path;false;GetFileName;(System.String);;Argument[0];ReturnValue;taint",
66+
"System.IO;Path;false;GetFileNameWithoutExtension;(System.ReadOnlySpan<System.Char>);;Argument[0];ReturnValue;taint",
67+
"System.IO;Path;false;GetFileNameWithoutExtension;(System.String);;Argument[0];ReturnValue;taint",
68+
"System.IO;Path;false;GetFullPath;(System.String);;Argument[0];ReturnValue;taint",
69+
"System.IO;Path;false;GetFullPath;(System.String,System.String);;Argument[0];ReturnValue;taint",
70+
"System.IO;Path;false;GetPathRoot;(System.ReadOnlySpan<System.Char>);;Argument[0];ReturnValue;taint",
71+
"System.IO;Path;false;GetPathRoot;(System.String);;Argument[0];ReturnValue;taint",
72+
"System.IO;Path;false;GetRelativePath;(System.String,System.String);;Argument[1];ReturnValue;taint"
73+
]
74+
}
75+
}
76+
4577
/** Data flow for `System.IO.TextReader`. */
4678
private class SystemIOTextReaderFlowModelCsv extends SummaryModelCsv {
4779
override predicate row(string row) {

0 commit comments

Comments
 (0)