Skip to content

Commit 9b31b61

Browse files
Broaden the scope of checks for authorization attributes
1 parent 7eea191 commit 9b31b61

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

csharp/ql/lib/semmle/code/csharp/security/auth/MissingFunctionLevelAccessControlQuery.qll

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,12 @@ predicate hasAuthViaXml(ActionMethod m) {
166166
)
167167
}
168168

169-
/** Holds if the given action has an `Authorize` attribute. */
169+
/** Holds if the given action has an attribute that indications authorization. */
170170
predicate hasAuthViaAttribute(ActionMethod m) {
171-
[m.getAnAttribute(), m.getDeclaringType().getAnAttribute()]
172-
.getType()
173-
.hasQualifiedName("Microsoft.AspNetCore.Authorization", "AuthorizeAttribute")
171+
exists(Attribute attr | attr.getType().getName().toLowerCase().matches("%auth%") |
172+
attr = m.getAnAttribute() or
173+
attr = m.getDeclaringType().getABaseType*().getAnAttribute()
174+
)
174175
}
175176

176177
/** Holds if `m` is a method that should have an auth check, but is missing it. */

0 commit comments

Comments
 (0)