Skip to content

Commit 8524a48

Browse files
authored
Merge pull request #8 from GitHubSecurityLab/docs-keyvault
docs: Update Key Vault docs
2 parents 05ba854 + 18a3cd8 commit 8524a48

File tree

1 file changed

+117
-1
lines changed

1 file changed

+117
-1
lines changed

ql/lib/codeql/bicep/frameworks/Microsoft/KeyVault.qll

Lines changed: 117 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,48 @@
11
private import bicep
22
private import codeql.bicep.Concepts
3-
private import Network
43

54
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+
*/
69
class VaultResource extends Resource {
710
/**
811
* Constructs a VaultResource for any Microsoft.KeyVault resource type.
12+
* Matches resources with type starting with "Microsoft.KeyVault/".
913
*/
1014
VaultResource() { this.getResourceType().regexpMatch("^Microsoft.KeyVault/.*") }
1115

16+
/**
17+
* Gets the tenant ID for the Key Vault resource.
18+
*/
1219
string tenantId() { result = this.getProperties().getTenantId().getValue() }
1320

21+
/**
22+
* Gets the properties object for the Key Vault resource.
23+
*/
1424
KeyVaultProperties::Properties getProperties() { result = this.getProperty("properties") }
1525

26+
/**
27+
* Gets the access policies for the Key Vault resource.
28+
*/
1629
KeyVaultProperties::AccessPolicy getAccessPolicies() {
1730
result = this.getProperties().getAccessPolicies()
1831
}
1932

33+
/**
34+
* Gets the network ACLs for the Key Vault resource.
35+
*/
2036
Network::NetworkAcl getNetworkAcls() {
2137
result = this.getProperties().getNetworkAcls()
2238
}
2339

2440
override string toString() { result = "Key Vault Resource" }
2541
}
2642

43+
/**
44+
* Represents a public Microsoft.KeyVault resource with public network access enabled.
45+
*/
2746
class PublicVaultResource extends PublicResource {
2847
private VaultResource vaultResource;
2948

@@ -36,6 +55,9 @@ module KeyVault {
3655
this = vaultResource
3756
}
3857

58+
/**
59+
* Gets the property that indicates public network access for the Key Vault resource.
60+
*/
3961
override Expr getPublicAccessProperty() {
4062
result = vaultResource.getProperties().getPublicNetworkAccess()
4163
}
@@ -46,6 +68,7 @@ module KeyVault {
4668
module KeyVaultProperties {
4769
/**
4870
* The properties object for the Microsoft.KeyVault/vaults type.
71+
* Provides access to Key Vault configuration and settings.
4972
*/
5073
class Properties extends Object {
5174
private VaultResource vaultResource;
@@ -60,57 +83,117 @@ module KeyVault {
6083
*/
6184
VaultResource getVaultResource() { result = vaultResource }
6285

86+
/**
87+
* Gets the tenant ID property.
88+
*/
6389
StringLiteral getTenantId() { result = this.getProperty("tenantId") }
6490

91+
/**
92+
* Gets the tenant ID value.
93+
*/
6594
string tenantId() { result = this.getTenantId().getValue() }
6695

96+
/**
97+
* Gets the create mode property.
98+
*/
6799
StringLiteral getCreateMode() { result = this.getProperty("createMode") }
68100

101+
/**
102+
* Gets the create mode value.
103+
*/
69104
string createMode() { result = this.getCreateMode().getValue() }
70105

106+
/**
107+
* Gets the enabledForDeployment property.
108+
*/
71109
Boolean getEnabledForDeployment() { result = this.getProperty("enabledForDeployment") }
72110

111+
/**
112+
* Returns true if enabled for deployment.
113+
*/
73114
boolean enabledForDeployment() { result = this.getEnabledForDeployment().getBool() }
74115

116+
/**
117+
* Gets the enabledForDiskEncryption property.
118+
*/
75119
Boolean getEnabledForDiskEncryption() {
76120
result = this.getProperty("enabledForDiskEncryption")
77121
}
78122

123+
/**
124+
* Returns true if enabled for disk encryption.
125+
*/
79126
boolean enabledForDiskEncryption() { result = this.getEnabledForDiskEncryption().getBool() }
80127

128+
/**
129+
* Gets the enabledForTemplateDeployment property.
130+
*/
81131
Boolean getEnabledForTemplateDeployment() {
82132
result = this.getProperty("enabledForTemplateDeployment")
83133
}
84134

135+
/**
136+
* Returns true if enabled for template deployment.
137+
*/
85138
boolean enabledForTemplateDeployment() {
86139
result = this.getEnabledForTemplateDeployment().getBool()
87140
}
88141

142+
/**
143+
* Gets the softDeleteEnabled property.
144+
*/
89145
Boolean getSoftDeleteEnabled() { result = this.getProperty("softDeleteEnabled") }
90146

147+
/**
148+
* Returns true if soft delete is enabled.
149+
*/
91150
boolean softDeleteEnabled() { result = this.getSoftDeleteEnabled().getBool() }
92151

152+
/**
153+
* Gets the purgeProtectionEnabled property.
154+
*/
93155
Boolean getPurgeProtectionEnabled() { result = this.getProperty("purgeProtectionEnabled") }
94156

157+
/**
158+
* Returns true if purge protection is enabled.
159+
*/
95160
boolean purgeProtectionEnabled() { result = this.getPurgeProtectionEnabled().getBool() }
96161

162+
/**
163+
* Gets the publicNetworkAccess property.
164+
*/
97165
StringLiteral getPublicNetworkAccess() { result = this.getProperty("publicNetworkAccess") }
98166

167+
/**
168+
* Gets the public network access value.
169+
*/
99170
string publicNetworkAccess() { result = this.getPublicNetworkAccess().getValue() }
100171

172+
/**
173+
* Gets the network ACLs for the Key Vault.
174+
*/
101175
Network::NetworkAcl getNetworkAcls() {
102176
result = this.getProperty("networkAcls")
103177
}
104178

179+
/**
180+
* Gets all access policies for the Key Vault.
181+
*/
105182
AccessPolicy getAccessPolicies() {
106183
result = this.getProperty("accessPolicies").(Array).getElements()
107184
}
108185

186+
/**
187+
* Gets a specific access policy by index.
188+
*/
109189
AccessPolicy getAccessPolicy(int index) {
110190
result = this.getProperty("accessPolicies").(Array).getElement(index)
111191
}
112192
}
113193

194+
/**
195+
* Represents an access policy for a Key Vault resource.
196+
*/
114197
class AccessPolicy extends Object {
115198
private KeyVaultProperties::Properties properties;
116199

@@ -129,9 +212,15 @@ module KeyVault {
129212
*/
130213
string getObjectId() { result = this.getProperty("objectId").(StringLiteral).getValue() }
131214

215+
/**
216+
* Returns a string representation of the access policy.
217+
*/
132218
string toString() { result = "AccessPolicy" }
133219
}
134220

221+
/**
222+
* Represents the permissions associated with a Key Vault access policy.
223+
*/
135224
class AccessPolicyPermissions extends Object {
136225
private AccessPolicy accessPolicy;
137226

@@ -140,22 +229,49 @@ module KeyVault {
140229
*/
141230
AccessPolicyPermissions() { this = accessPolicy.getProperty("permissions") }
142231

232+
/**
233+
* Gets the certificates permissions array.
234+
*/
143235
Array getCertificates() { result = this.getProperty("certificates") }
144236

237+
/**
238+
* Gets a certificate permission by index.
239+
*/
145240
StringLiteral getCertificate(int index) { result = this.getCertificates().getElement(index) }
146241

242+
/**
243+
* Gets the keys permissions array.
244+
*/
147245
Array getKeys() { result = this.getProperty("keys") }
148246

247+
/**
248+
* Gets a key permission by index.
249+
*/
149250
StringLiteral getKey(int index) { result = this.getKeys().getElement(index) }
150251

252+
/**
253+
* Gets the secrets permissions array.
254+
*/
151255
Array getSecrets() { result = this.getProperty("secrets") }
152256

257+
/**
258+
* Gets a secret permission by index.
259+
*/
153260
StringLiteral getSecret(int index) { result = this.getSecrets().getElement(index) }
154261

262+
/**
263+
* Gets the storage permissions array.
264+
*/
155265
Array getStorages() { result = this.getProperty("storage") }
156266

267+
/**
268+
* Gets a storage permission by index.
269+
*/
157270
StringLiteral getStorage(int index) { result = this.getStorages().getElement(index) }
158271

272+
/**
273+
* Returns a string representation of the access policy permissions.
274+
*/
159275
string toString() { result = "AccessPolicyPermissions" }
160276
}
161277
}

0 commit comments

Comments
 (0)