Skip to content

Commit cf75493

Browse files
committed
C#: Consider Enums and System.DateTimeOffset as having a sanitizing effect.
1 parent 0815989 commit cf75493

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

csharp/ql/lib/semmle/code/csharp/frameworks/System.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,11 @@ class SystemDateTimeStruct extends SystemStruct {
756756
SystemDateTimeStruct() { this.hasName("DateTime") }
757757
}
758758

759+
/** The `System.DateTimeOffset` struct. */
760+
class SystemDateTimeOffsetStruct extends SystemStruct {
761+
SystemDateTimeOffsetStruct() { this.hasName("DateTimeOffset") }
762+
}
763+
759764
/** The `System.Span<T>` struct. */
760765
class SystemSpanStruct extends SystemUnboundGenericStruct {
761766
SystemSpanStruct() {

csharp/ql/lib/semmle/code/csharp/security/Sanitizers.qll

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ class SimpleTypeSanitizedExpr extends DataFlow::ExprNode {
5757
SimpleTypeSanitizedExpr() {
5858
exists(Type t | t = this.getType() or t = this.getType().(NullableType).getUnderlyingType() |
5959
t instanceof SimpleType or
60-
t instanceof SystemDateTimeStruct
61-
// or t instanceof Enum
60+
t instanceof SystemDateTimeStruct or
61+
t instanceof SystemDateTimeOffsetStruct or
62+
t instanceof Enum
6263
)
6364
}
6465
}

0 commit comments

Comments
 (0)