1
1
private import bicep
2
2
private import codeql.bicep.Concepts
3
- private import Network
4
3
5
4
module KeyVault {
5
+ /**
6
+ * Represents a Microsoft.KeyVault resource in a Bicep file.
7
+ * Provides access to Key Vault properties, access policies, and network ACLs.
8
+ */
6
9
class VaultResource extends Resource {
7
10
/**
8
11
* Constructs a VaultResource for any Microsoft.KeyVault resource type.
12
+ * Matches resources with type starting with "Microsoft.KeyVault/".
9
13
*/
10
14
VaultResource ( ) { this .getResourceType ( ) .regexpMatch ( "^Microsoft.KeyVault/.*" ) }
11
15
16
+ /**
17
+ * Gets the tenant ID for the Key Vault resource.
18
+ */
12
19
string tenantId ( ) { result = this .getProperties ( ) .getTenantId ( ) .getValue ( ) }
13
20
21
+ /**
22
+ * Gets the properties object for the Key Vault resource.
23
+ */
14
24
KeyVaultProperties:: Properties getProperties ( ) { result = this .getProperty ( "properties" ) }
15
25
26
+ /**
27
+ * Gets the access policies for the Key Vault resource.
28
+ */
16
29
KeyVaultProperties:: AccessPolicy getAccessPolicies ( ) {
17
30
result = this .getProperties ( ) .getAccessPolicies ( )
18
31
}
19
32
33
+ /**
34
+ * Gets the network ACLs for the Key Vault resource.
35
+ */
20
36
Network:: NetworkAcl getNetworkAcls ( ) {
21
37
result = this .getProperties ( ) .getNetworkAcls ( )
22
38
}
23
39
24
40
override string toString ( ) { result = "Key Vault Resource" }
25
41
}
26
42
43
+ /**
44
+ * Represents a public Microsoft.KeyVault resource with public network access enabled.
45
+ */
27
46
class PublicVaultResource extends PublicResource {
28
47
private VaultResource vaultResource ;
29
48
@@ -36,6 +55,9 @@ module KeyVault {
36
55
this = vaultResource
37
56
}
38
57
58
+ /**
59
+ * Gets the property that indicates public network access for the Key Vault resource.
60
+ */
39
61
override Expr getPublicAccessProperty ( ) {
40
62
result = vaultResource .getProperties ( ) .getPublicNetworkAccess ( )
41
63
}
@@ -46,6 +68,7 @@ module KeyVault {
46
68
module KeyVaultProperties {
47
69
/**
48
70
* The properties object for the Microsoft.KeyVault/vaults type.
71
+ * Provides access to Key Vault configuration and settings.
49
72
*/
50
73
class Properties extends Object {
51
74
private VaultResource vaultResource ;
@@ -60,57 +83,117 @@ module KeyVault {
60
83
*/
61
84
VaultResource getVaultResource ( ) { result = vaultResource }
62
85
86
+ /**
87
+ * Gets the tenant ID property.
88
+ */
63
89
StringLiteral getTenantId ( ) { result = this .getProperty ( "tenantId" ) }
64
90
91
+ /**
92
+ * Gets the tenant ID value.
93
+ */
65
94
string tenantId ( ) { result = this .getTenantId ( ) .getValue ( ) }
66
95
96
+ /**
97
+ * Gets the create mode property.
98
+ */
67
99
StringLiteral getCreateMode ( ) { result = this .getProperty ( "createMode" ) }
68
100
101
+ /**
102
+ * Gets the create mode value.
103
+ */
69
104
string createMode ( ) { result = this .getCreateMode ( ) .getValue ( ) }
70
105
106
+ /**
107
+ * Gets the enabledForDeployment property.
108
+ */
71
109
Boolean getEnabledForDeployment ( ) { result = this .getProperty ( "enabledForDeployment" ) }
72
110
111
+ /**
112
+ * Returns true if enabled for deployment.
113
+ */
73
114
boolean enabledForDeployment ( ) { result = this .getEnabledForDeployment ( ) .getBool ( ) }
74
115
116
+ /**
117
+ * Gets the enabledForDiskEncryption property.
118
+ */
75
119
Boolean getEnabledForDiskEncryption ( ) {
76
120
result = this .getProperty ( "enabledForDiskEncryption" )
77
121
}
78
122
123
+ /**
124
+ * Returns true if enabled for disk encryption.
125
+ */
79
126
boolean enabledForDiskEncryption ( ) { result = this .getEnabledForDiskEncryption ( ) .getBool ( ) }
80
127
128
+ /**
129
+ * Gets the enabledForTemplateDeployment property.
130
+ */
81
131
Boolean getEnabledForTemplateDeployment ( ) {
82
132
result = this .getProperty ( "enabledForTemplateDeployment" )
83
133
}
84
134
135
+ /**
136
+ * Returns true if enabled for template deployment.
137
+ */
85
138
boolean enabledForTemplateDeployment ( ) {
86
139
result = this .getEnabledForTemplateDeployment ( ) .getBool ( )
87
140
}
88
141
142
+ /**
143
+ * Gets the softDeleteEnabled property.
144
+ */
89
145
Boolean getSoftDeleteEnabled ( ) { result = this .getProperty ( "softDeleteEnabled" ) }
90
146
147
+ /**
148
+ * Returns true if soft delete is enabled.
149
+ */
91
150
boolean softDeleteEnabled ( ) { result = this .getSoftDeleteEnabled ( ) .getBool ( ) }
92
151
152
+ /**
153
+ * Gets the purgeProtectionEnabled property.
154
+ */
93
155
Boolean getPurgeProtectionEnabled ( ) { result = this .getProperty ( "purgeProtectionEnabled" ) }
94
156
157
+ /**
158
+ * Returns true if purge protection is enabled.
159
+ */
95
160
boolean purgeProtectionEnabled ( ) { result = this .getPurgeProtectionEnabled ( ) .getBool ( ) }
96
161
162
+ /**
163
+ * Gets the publicNetworkAccess property.
164
+ */
97
165
StringLiteral getPublicNetworkAccess ( ) { result = this .getProperty ( "publicNetworkAccess" ) }
98
166
167
+ /**
168
+ * Gets the public network access value.
169
+ */
99
170
string publicNetworkAccess ( ) { result = this .getPublicNetworkAccess ( ) .getValue ( ) }
100
171
172
+ /**
173
+ * Gets the network ACLs for the Key Vault.
174
+ */
101
175
Network:: NetworkAcl getNetworkAcls ( ) {
102
176
result = this .getProperty ( "networkAcls" )
103
177
}
104
178
179
+ /**
180
+ * Gets all access policies for the Key Vault.
181
+ */
105
182
AccessPolicy getAccessPolicies ( ) {
106
183
result = this .getProperty ( "accessPolicies" ) .( Array ) .getElements ( )
107
184
}
108
185
186
+ /**
187
+ * Gets a specific access policy by index.
188
+ */
109
189
AccessPolicy getAccessPolicy ( int index ) {
110
190
result = this .getProperty ( "accessPolicies" ) .( Array ) .getElement ( index )
111
191
}
112
192
}
113
193
194
+ /**
195
+ * Represents an access policy for a Key Vault resource.
196
+ */
114
197
class AccessPolicy extends Object {
115
198
private KeyVaultProperties:: Properties properties ;
116
199
@@ -129,9 +212,15 @@ module KeyVault {
129
212
*/
130
213
string getObjectId ( ) { result = this .getProperty ( "objectId" ) .( StringLiteral ) .getValue ( ) }
131
214
215
+ /**
216
+ * Returns a string representation of the access policy.
217
+ */
132
218
string toString ( ) { result = "AccessPolicy" }
133
219
}
134
220
221
+ /**
222
+ * Represents the permissions associated with a Key Vault access policy.
223
+ */
135
224
class AccessPolicyPermissions extends Object {
136
225
private AccessPolicy accessPolicy ;
137
226
@@ -140,22 +229,49 @@ module KeyVault {
140
229
*/
141
230
AccessPolicyPermissions ( ) { this = accessPolicy .getProperty ( "permissions" ) }
142
231
232
+ /**
233
+ * Gets the certificates permissions array.
234
+ */
143
235
Array getCertificates ( ) { result = this .getProperty ( "certificates" ) }
144
236
237
+ /**
238
+ * Gets a certificate permission by index.
239
+ */
145
240
StringLiteral getCertificate ( int index ) { result = this .getCertificates ( ) .getElement ( index ) }
146
241
242
+ /**
243
+ * Gets the keys permissions array.
244
+ */
147
245
Array getKeys ( ) { result = this .getProperty ( "keys" ) }
148
246
247
+ /**
248
+ * Gets a key permission by index.
249
+ */
149
250
StringLiteral getKey ( int index ) { result = this .getKeys ( ) .getElement ( index ) }
150
251
252
+ /**
253
+ * Gets the secrets permissions array.
254
+ */
151
255
Array getSecrets ( ) { result = this .getProperty ( "secrets" ) }
152
256
257
+ /**
258
+ * Gets a secret permission by index.
259
+ */
153
260
StringLiteral getSecret ( int index ) { result = this .getSecrets ( ) .getElement ( index ) }
154
261
262
+ /**
263
+ * Gets the storage permissions array.
264
+ */
155
265
Array getStorages ( ) { result = this .getProperty ( "storage" ) }
156
266
267
+ /**
268
+ * Gets a storage permission by index.
269
+ */
157
270
StringLiteral getStorage ( int index ) { result = this .getStorages ( ) .getElement ( index ) }
158
271
272
+ /**
273
+ * Returns a string representation of the access policy permissions.
274
+ */
159
275
string toString ( ) { result = "AccessPolicyPermissions" }
160
276
}
161
277
}
0 commit comments