mirror of
https://github.com/github/codeql.git
synced 2026-04-22 07:15:15 +02:00
C#: Consider string.ReplaceLineEndings(string) as a sanitizer for log forging.
This commit is contained in:
@@ -354,6 +354,14 @@ class SystemStringClass extends StringType {
|
||||
result.getReturnType() instanceof StringType
|
||||
}
|
||||
|
||||
/** Gets the `ReplaceLineEndings(string) method. */
|
||||
Method getReplaceLineEndingsMethod() {
|
||||
result.getDeclaringType() = this and
|
||||
result.hasName("ReplaceLineEndings") and
|
||||
result.getNumberOfParameters() = 1 and
|
||||
result.getReturnType() instanceof StringType
|
||||
}
|
||||
|
||||
/** Gets a `Format(...)` method. */
|
||||
Method getFormatMethod() {
|
||||
result.getDeclaringType() = this and
|
||||
|
||||
@@ -70,7 +70,9 @@ private class ExternalLoggingExprSink extends Sink {
|
||||
private class StringReplaceSanitizer extends Sanitizer {
|
||||
StringReplaceSanitizer() {
|
||||
exists(Method m |
|
||||
exists(SystemStringClass s | m = s.getReplaceMethod() or m = s.getRemoveMethod())
|
||||
exists(SystemStringClass s |
|
||||
m = s.getReplaceMethod() or m = s.getRemoveMethod() or m = s.getReplaceLineEndingsMethod()
|
||||
)
|
||||
or
|
||||
m = any(SystemTextRegularExpressionsRegexClass r).getAReplaceMethod()
|
||||
|
|
||||
|
||||
Reference in New Issue
Block a user