Skip to content

Commit fac9944

Browse files
Copilotfelickz
andcommitted
Fix imports and simplify security library
Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>
1 parent 1c00525 commit fac9944

File tree

2 files changed

+25
-51
lines changed

2 files changed

+25
-51
lines changed

ql/lib/codeql/bicep/Frameworks.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import frameworks.Microsoft.Containers
44
import frameworks.Microsoft.Dashboards
55
import frameworks.Microsoft.General
66
import frameworks.Microsoft.AKS
7+
import frameworks.Microsoft.Authorization
78
import frameworks.Microsoft.Profiles
89
import frameworks.Microsoft.Network
910
import frameworks.Microsoft.Storage

ql/lib/codeql/bicep/security/OverlyPermissiveAccessControl.qll

Lines changed: 24 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -6,60 +6,9 @@
66
*/
77

88
private import bicep
9-
private import codeql.bicep.dataflow.DataFlow
109
private import codeql.bicep.frameworks.Microsoft.Authorization
1110

1211
module OverlyPermissiveAccessControl {
13-
/** A data flow source for overly permissive access control vulnerabilities. */
14-
abstract class Source extends DataFlow::Node { }
15-
16-
/** A data flow sink for overly permissive access control vulnerabilities. */
17-
abstract class Sink extends DataFlow::Node { }
18-
19-
/** A sanitizer for overly permissive access control vulnerabilities. */
20-
abstract class Sanitizer extends DataFlow::Node { }
21-
22-
/**
23-
* A role assignment resource that grants privileged roles at broad scopes.
24-
*/
25-
private class OverlyPermissiveRoleAssignment extends Source {
26-
Authorization::RoleAssignmentResource roleAssignment;
27-
28-
OverlyPermissiveRoleAssignment() {
29-
this.asExpr() = roleAssignment.getResourceDeclaration() and
30-
roleAssignment.isOverlyPermissive()
31-
}
32-
33-
/**
34-
* Gets the role assignment resource.
35-
*/
36-
Authorization::RoleAssignmentResource getRoleAssignment() { result = roleAssignment }
37-
38-
/**
39-
* Gets a description of why this role assignment is overly permissive.
40-
*/
41-
string getDescription() {
42-
exists(string role, string scope |
43-
(
44-
roleAssignment.getRoleDefinitionId() = "8e3af657-a8ff-443c-a75c-2fe8c4bcb635" and
45-
role = "Owner"
46-
or
47-
roleAssignment.getRoleDefinitionId() = "b24988ac-6180-42a0-ab88-20f7382dd24c" and
48-
role = "Contributor"
49-
or
50-
roleAssignment.getRoleDefinitionId() = "18d7d88d-d35e-4fb5-a5c3-7773c20a72d9" and
51-
role = "User Access Administrator"
52-
) and
53-
(
54-
roleAssignment.isSubscriptionScoped() and scope = "subscription"
55-
or
56-
roleAssignment.isResourceGroupScoped() and scope = "resource group"
57-
) and
58-
result = role + " role assigned at " + scope + " scope"
59-
)
60-
}
61-
}
62-
6312
/**
6413
* Predicate to identify role assignments with overly broad scope.
6514
*/
@@ -80,4 +29,28 @@ module OverlyPermissiveAccessControl {
8029
predicate isOverlyPermissive(Authorization::RoleAssignmentResource roleAssignment) {
8130
roleAssignment.isOverlyPermissive()
8231
}
32+
33+
/**
34+
* Gets a description of why a role assignment is overly permissive.
35+
*/
36+
string getPermissiveDescription(Authorization::RoleAssignmentResource roleAssignment) {
37+
exists(string role, string scope |
38+
(
39+
roleAssignment.getRoleDefinitionId() = "8e3af657-a8ff-443c-a75c-2fe8c4bcb635" and
40+
role = "Owner"
41+
or
42+
roleAssignment.getRoleDefinitionId() = "b24988ac-6180-42a0-ab88-20f7382dd24c" and
43+
role = "Contributor"
44+
or
45+
roleAssignment.getRoleDefinitionId() = "18d7d88d-d35e-4fb5-a5c3-7773c20a72d9" and
46+
role = "User Access Administrator"
47+
) and
48+
(
49+
roleAssignment.isSubscriptionScoped() and scope = "subscription"
50+
or
51+
roleAssignment.isResourceGroupScoped() and scope = "resource group"
52+
) and
53+
result = role + " role assigned at " + scope + " scope"
54+
)
55+
}
8356
}

0 commit comments

Comments
 (0)