-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompute.qll
More file actions
278 lines (233 loc) · 8.2 KB
/
Compute.qll
File metadata and controls
278 lines (233 loc) · 8.2 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
private import bicep
/**
* A resource of type Microsoft.Compute/virtualMachines
*/
module Compute {
/**
* Represents a generic Microsoft.Compute resource.
* Matches any resource of type Microsoft.Compute/*.
*/
class ComputeResource extends AzureResource {
/**
* Constructs a ComputeResource for any Microsoft.Compute resource type.
*/
ComputeResource() { this.getResourceType().regexpMatch("^Microsoft.Compute/.*") }
}
/**
* Represents a Microsoft.Compute/virtualMachines resource.
* See: https://learn.microsoft.com/en-us/azure/templates/microsoft.compute/virtualmachines
*/
class VirtualMachines extends ComputeResource {
/**
* Constructs a VirtualMachines resource.
*/
VirtualMachines() {
this.getResourceType().regexpMatch("^Microsoft.Compute/virtualMachines@.*")
}
/**
* Returns a string representation of the VirtualMachines resource.
*/
override string toString() { result = "VirtualMachines Resource" }
/**
* Returns the properties object for this virtual machine.
*/
VirtualMachinesProperties::Properties getProperties() {
result = this.getProperty("properties")
}
/**
* Returns the hardware network interfaces of the virtual machine.
*/
Network::NetworkInterfaces getNetworkInterfaces() {
result = this.getProperties().getNetworkProfile().getNetworkInterfaces()
}
}
/**
* The properties module for Microsoft.Compute/virtualMachines resources.
*/
module VirtualMachinesProperties {
/**
* The properties object for the Microsoft.Compute/virtualMachines type.
*/
class Properties extends ResourceProperties {
private VirtualMachines virtualMachines;
/**
* Constructs a Properties object for the given virtual machine.
*/
Properties() { this = virtualMachines.getProperty("properties") }
/**
* Returns the parent VirtualMachines resource.
*/
VirtualMachines getVirtualMachine() { result = virtualMachines }
/**
* Returns the hardware profile object for the virtual machine.
*/
HardwareProfile getHardwareProfile() { result = this.getProperty("hardwareProfile") }
/**
* Returns the network profile object for the virtual machine.
*/
NetworkProfile getNetworkProfile() { result = this.getProperty("networkProfile") }
/**
* Returns the OS profile object for the virtual machine.
*/
Compute::Profiles::OsProfile getOsProfile() { result = this.getProperty("osProfile") }
override string toString() {
result = "VirtualMachinesProperties[" + virtualMachines.getName() + "]"
}
}
/**
* The hardwareProfile property object for the Microsoft.Compute/virtualMachines type.
*/
class HardwareProfile extends Object {
private Properties properties;
/**
* Constructs a HardwareProfile object for the given properties.
*/
HardwareProfile() { this = properties.getProperty("hardwareProfile") }
/**
* Returns a string representation of the hardware profile.
*/
string toString() { result = "HardwareProfile" }
/**
* Returns the vmSize property of the hardware profile.
*/
Expr getVmSize() { result = this.getProperty("vmSize") }
}
/**
* Represents a network profile for the Microsoft.Compute/virtualMachines type.
*/
class NetworkProfile extends Object {
private Properties properties;
/**
* Constructs a NetworkProfile object for the given properties.
*/
NetworkProfile() { this = properties.getProperty("networkProfile") }
/**
* Returns a string representation of the network profile.
*/
string toString() { result = "NetworkProfile" }
/**
* Returns the network interfaces for the virtual machine.
*/
Network::NetworkInterfaces getNetworkInterfaces() {
result = resolveResource(this.getNetworkInterfacesObject())
}
/**
* Returns the networkInterfaces property as an object array.
*/
private Object getNetworkInterfacesObject() {
result = this.getProperty("networkInterfaces").(Array).getElements()
}
}
/**
* Represents the storage profile for the Microsoft.Compute/virtualMachines type.
*/
class StorageProfile extends Object {
private Properties properties;
/**
* Constructs a StorageProfile object for the given properties.
*/
StorageProfile() { this = properties.getProperty("storageProfile") }
/**
* Returns the image reference for the storage profile.
*/
ImageReference getImageReference() { result = this.getProperty("imageReference") }
}
/**
* Represents an image reference for the Microsoft.Compute/virtualMachines type.
* See: https://learn.microsoft.com/en-us/azure/templates/microsoft.compute/virtualmachines?pivots=deployment-language-bicep#imagereference
*/
class ImageReference extends Object {
private StorageProfile storageProfile;
/**
* Constructs an ImageReference object for the given storage profile.
*/
ImageReference() { this = storageProfile.getProperty("imageReference") }
/**
* Returns the publisher property of the image reference.
*/
Expr getPublisher() { result = this.getProperty("publisher") }
/**
* Returns the offer property of the image reference.
*/
Expr getOffer() { result = this.getProperty("offer") }
/**
* Returns the sku property of the image reference.
*/
Expr getSku() { result = this.getProperty("sku") }
/**
* Returns the version property of the image reference.
*/
Expr getVersion() { result = this.getProperty("version") }
}
}
module Profiles {
/**
* Represents the OS profile for the Microsoft.Compute/virtualMachines type.
*/
class OsProfile extends Object {
private ResourceProperties properties;
private string profileType;
/**
* Constructs an OsProfile object for the given properties.
*/
OsProfile() {
this = properties.getProperty("osProfile") and profileType = "general"
or
this = properties.getProperty("linuxProfile") and profileType = "linux"
or
this = properties.getProperty("windowsProfile") and profileType = "windows"
}
/**
* Returns the computerName property of the OS profile.
*/
Expr getComputerName() { result = this.getProperty("computerName") }
string osType() {
result = profileType
}
/**
* Returns the adminUsername property of the OS profile.
*/
Expr getAdminUsername() { result = this.getProperty("adminUsername") }
/**
* Returns the adminPassword property of the OS profile.
*/
Expr getAdminPassword() { result = this.getProperty("adminPassword") }
SshConfig getSshConfig() {
result = this.getProperty("ssh")
}
string toString() {
result = "OsProfile[" + profileType + "]"
}
}
class SshConfig extends Object {
private OsProfile osProfile;
/**
* Constructs an SshConfig object for the given OS profile.
*/
SshConfig() { this = osProfile.getProperty("ssh") }
/**
* Returns the publicKeys property of the SSH configuration.
*/
SshPublicKey getPublicKeys() { result = this.getProperty("publicKeys").(Array).getElements() }
/**
* Returns a string representation of the SSH configuration.
*/
string toString() { result = "SshConfig" }
}
class SshPublicKey extends Object {
private SshConfig sshConfig;
/**
* Constructs an SshConfigPublicKey object for the given SSH configuration.
*/
SshPublicKey() { this = sshConfig.getProperty("publicKeys").(Array).getElements() }
/**
* Returns the keyData property of the SSH public key.
*/
Expr getKeyData() { result = this.getProperty("keyData") }
/**
* Returns a string representation of the SSH public key.
*/
string toString() { result = "SshConfigPublicKey" }
}
}
}