-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeyVault.qll
More file actions
162 lines (114 loc) · 5.3 KB
/
KeyVault.qll
File metadata and controls
162 lines (114 loc) · 5.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
private import bicep
private import codeql.bicep.Concepts
private import Network
module KeyVault {
class VaultResource extends Resource {
/**
* Constructs a VaultResource for any Microsoft.KeyVault resource type.
*/
VaultResource() { this.getResourceType().regexpMatch("^Microsoft.KeyVault/.*") }
string tenantId() { result = this.getProperties().getTenantId().getValue() }
KeyVaultProperties::Properties getProperties() { result = this.getProperty("properties") }
KeyVaultProperties::AccessPolicy getAccessPolicies() {
result = this.getProperties().getAccessPolicies()
}
Network::NetworkAcl getNetworkAcls() {
result = this.getProperties().getNetworkAcls()
}
override string toString() { result = "Key Vault Resource" }
}
class PublicVaultResource extends PublicResource {
private VaultResource vaultResource;
/**
* Constructs a PublicVaultResource for any Microsoft.KeyVault resource type
* that has public network access enabled.
*/
PublicVaultResource() {
vaultResource.getProperties().publicNetworkAccess() = "Enabled" and
this = vaultResource
}
override Expr getPublicAccessProperty() {
result = vaultResource.getProperties().getPublicNetworkAccess()
}
override string toString() { result = "Public Key Vault Resource" }
}
module KeyVaultProperties {
/**
* The properties object for the Microsoft.KeyVault/vaults type.
*/
class Properties extends Object {
private VaultResource vaultResource;
/**
* Constructs a Properties object for the given Key Vault resource.
*/
Properties() { this = vaultResource.getProperty("properties") }
/**
* Returns the parent VaultResource.
*/
VaultResource getVaultResource() { result = vaultResource }
StringLiteral getTenantId() { result = this.getProperty("tenantId") }
string tenantId() { result = this.getTenantId().getValue() }
StringLiteral getCreateMode() { result = this.getProperty("createMode") }
string createMode() { result = this.getCreateMode().getValue() }
Boolean getEnabledForDeployment() { result = this.getProperty("enabledForDeployment") }
boolean enabledForDeployment() { result = this.getEnabledForDeployment().getBool() }
Boolean getEnabledForDiskEncryption() {
result = this.getProperty("enabledForDiskEncryption")
}
boolean enabledForDiskEncryption() { result = this.getEnabledForDiskEncryption().getBool() }
Boolean getEnabledForTemplateDeployment() {
result = this.getProperty("enabledForTemplateDeployment")
}
boolean enabledForTemplateDeployment() {
result = this.getEnabledForTemplateDeployment().getBool()
}
Boolean getSoftDeleteEnabled() { result = this.getProperty("softDeleteEnabled") }
boolean softDeleteEnabled() { result = this.getSoftDeleteEnabled().getBool() }
Boolean getPurgeProtectionEnabled() { result = this.getProperty("purgeProtectionEnabled") }
boolean purgeProtectionEnabled() { result = this.getPurgeProtectionEnabled().getBool() }
StringLiteral getPublicNetworkAccess() { result = this.getProperty("publicNetworkAccess") }
string publicNetworkAccess() { result = this.getPublicNetworkAccess().getValue() }
Network::NetworkAcl getNetworkAcls() {
result = this.getProperty("networkAcls")
}
AccessPolicy getAccessPolicies() {
result = this.getProperty("accessPolicies").(Array).getElements()
}
AccessPolicy getAccessPolicy(int index) {
result = this.getProperty("accessPolicies").(Array).getElement(index)
}
}
class AccessPolicy extends Object {
private KeyVaultProperties::Properties properties;
/**
* Constructs an AccessPolicy object for the given Key Vault properties.
*/
AccessPolicy() { this = properties.getProperty("accessPolicies").(Array).getElements() }
/**
* Returns the tenant ID of the access policy.
*/
string getTenantId() { result = this.getProperty("tenantId").(StringLiteral).getValue() }
/**
* Returns the object ID of the access policy.
*/
string getObjectId() { result = this.getProperty("objectId").(StringLiteral).getValue() }
string toString() { result = "AccessPolicy" }
}
class AccessPolicyPermissions extends Object {
private AccessPolicy accessPolicy;
/**
* Constructs an AccessPolicyPermissions object for the given access policy.
*/
AccessPolicyPermissions() { this = accessPolicy.getProperty("permissions") }
Array getCertificates() { result = this.getProperty("certificates") }
StringLiteral getCertificate(int index) { result = this.getCertificates().getElement(index) }
Array getKeys() { result = this.getProperty("keys") }
StringLiteral getKey(int index) { result = this.getKeys().getElement(index) }
Array getSecrets() { result = this.getProperty("secrets") }
StringLiteral getSecret(int index) { result = this.getSecrets().getElement(index) }
Array getStorages() { result = this.getProperty("storage") }
StringLiteral getStorage(int index) { result = this.getStorages().getElement(index) }
string toString() { result = "AccessPolicyPermissions" }
}
}
}