Skip to content

Commit 43d7e59

Browse files
committed
C#: Treat GetFileName method call as sanitizer
Use the GetFileName call as a sanitizer, rather than an argument to that call. It is the _result_ of the GetFileName call which should be considered sanitized. By using the argument, we can spuriously suppress use-use flow. Consider: ``` var path = Path.Combine(destDir, entry.GetFullName()); var fileName = Path.GetFileName(path); log("Extracting " + fileName); entry.ExtractToFile(path); ``` Previously, the `ExtractToFile(path)` call would not have been flagged, because the `path` argument to `GetFileName` was considered sanitized, and that argument formed a use-use pair with the `path` argument to `ExtractToFile`. Now, this result would be flagged because only the result of the `GetFileName` call is considered sanitized.
1 parent d4551e5 commit 43d7e59

File tree

1 file changed

+1
-1
lines changed
  • csharp/ql/src/semmle/code/csharp/security/dataflow

1 file changed

+1
-1
lines changed

csharp/ql/src/semmle/code/csharp/security/dataflow/ZipSlip.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ module ZipSlip {
104104
GetFileNameSanitizer() {
105105
exists(MethodCall mc |
106106
mc.getTarget().hasQualifiedName("System.IO.Path", "GetFileName") |
107-
this.asExpr() = mc.getAnArgument()
107+
this.asExpr() = mc
108108
)
109109
}
110110
}

0 commit comments

Comments
 (0)