Skip to content

Commit 1b128a2

Browse files
committed
C#: Re-factor AuthCookieName to use the new API.
1 parent 1979a78 commit 1b128a2

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

csharp/ql/src/experimental/dataflow/flowsources/AuthCookie.qll

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,16 @@ import semmle.code.csharp.frameworks.microsoft.AspNetCore
99
* Holds if the expression is a variable with a sensitive name.
1010
*/
1111
predicate isCookieWithSensitiveName(Expr cookieExpr) {
12-
exists(AuthCookieNameConfiguration dataflow, DataFlow::Node sink |
13-
dataflow.hasFlowTo(sink) and
12+
exists(DataFlow::Node sink |
13+
AuthCookieName::flowTo(sink) and
1414
sink.asExpr() = cookieExpr
1515
)
1616
}
1717

1818
/**
19-
* Tracks if a variable with a sensitive name is used as an argument.
19+
* Configuration for tracking if a variable with a sensitive name is used as an argument.
2020
*/
21-
private class AuthCookieNameConfiguration extends DataFlow::Configuration {
22-
AuthCookieNameConfiguration() { this = "AuthCookieNameConfiguration" }
23-
21+
private module AuthCookieNameConfig implements DataFlow::ConfigSig {
2422
private predicate isAuthVariable(Expr expr) {
2523
exists(string val |
2624
(
@@ -32,13 +30,16 @@ private class AuthCookieNameConfiguration extends DataFlow::Configuration {
3230
)
3331
}
3432

35-
override predicate isSource(DataFlow::Node source) { isAuthVariable(source.asExpr()) }
33+
predicate isSource(DataFlow::Node source) { isAuthVariable(source.asExpr()) }
3634

37-
override predicate isSink(DataFlow::Node sink) {
38-
exists(Call c | sink.asExpr() = c.getAnArgument())
39-
}
35+
predicate isSink(DataFlow::Node sink) { exists(Call c | sink.asExpr() = c.getAnArgument()) }
4036
}
4137

38+
/**
39+
* Tracks if a variable with a sensitive name is used as an argument.
40+
*/
41+
private module AuthCookieName = DataFlow::Global<AuthCookieNameConfig>;
42+
4243
/**
4344
* DEPRECATED: Use `CookieOptionsTracking` instead.
4445
*

0 commit comments

Comments
 (0)