-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainers.qll
More file actions
482 lines (395 loc) · 14.1 KB
/
Containers.qll
File metadata and controls
482 lines (395 loc) · 14.1 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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
private import bicep
module Containers {
/**
* Represents a Microsoft.ContainerApp/containerApps resource (2025-02-02-preview).
* See: https://learn.microsoft.com/en-us/azure/templates/microsoft.app/containerapps
*/
class ContainerResource extends AzureResource {
/**
* Constructs a ContainerResource for Microsoft.App/containerApps resources.
*/
ContainerResource() { this.getResourceType().regexpMatch("^Microsoft.App/containerApps@.*") }
/**
* Returns the extendedLocation property.
*/
Expr getExtendedLocation() { result = this.getProperty("extendedLocation") }
/**
* Returns the identity property.
*/
Expr getIdentity() { result = this.getProperty("identity") }
/**
* Returns the kind property.
*/
StringLiteral getKind() { result = this.getProperty("kind") }
/**
* Returns the managedBy property.
*/
StringLiteral getManagedBy() { result = this.getProperty("managedBy") }
/**
* Returns the name property (overrides base Resource).
*/
override string getName() { result = super.getName() }
/**
* Returns the properties object for the container app resource.
*/
ContainerProperties::Properties getProperties() { result = this.getProperty("properties") }
/**
* Returns the configuration object for the container app resource.
*/
ContainerProperties::ContainerConfiguration getConfiguration() {
result = this.getProperties().getConfiguration()
}
/**
* Returns the template object for the container app resource.
*/
ContainerProperties::ContainerTemplate getTemplate() {
result = this.getProperties().getTemplate()
}
/**
* Returns the containers defined in the template.
*/
ContainerProperties::ContainerApp getContainers() {
result = this.getTemplate().getContainers()
}
/**
* Returns a specific container by index from the template.
*/
ContainerProperties::ContainerApp getContainer(int index) {
result = this.getTemplate().getContainer(index)
}
Network::Ingress getNetworkIngress() { result = this.getConfiguration().getNetworkIngress() }
Network::CorsPolicy getCorsPolicy() { result = this.getNetworkIngress().getCorsPolicy() }
/**
* Returns a string representation of the container app resource.
*/
override string toString() { result = "ContainerResource" }
}
class ContainerRegistry extends AzureResource {
/**
* Constructs a ContainerRegistry for Microsoft.ContainerRegistry/containerRegistries resources (2025-02-02-preview).
*/
ContainerRegistry() {
this.getResourceType().regexpMatch("^Microsoft.ContainerRegistry/registries@.*$")
}
override string toString() { result = "ContainerRegistry" }
}
module ContainerProperties {
/**
* Represents the properties object for a container app resource (2025-02-02-preview).
*/
class Properties extends ResourceProperties {
private ContainerResource containerResource;
/**
* Constructs a Properties object for the given container app resource.
*/
Properties() { this = containerResource.getProperty("properties") }
/**
* Returns the parent ContainerResource.
*/
ContainerResource getContainerResource() { result = containerResource }
/**
* Returns the configuration property.
*/
ContainerConfiguration getConfiguration() { result = this.getProperty("configuration") }
/**
* Returns the environmentId property.
*/
StringLiteral getEnvironmentId() { result = this.getProperty("environmentId") }
/**
* Returns the managedEnvironmentId property.
*/
StringLiteral getManagedEnvironmentId() { result = this.getProperty("managedEnvironmentId") }
/**
* Returns the patchingConfiguration property.
*/
Expr getPatchingConfiguration() { result = this.getProperty("patchingConfiguration") }
/**
* Returns the template property.
*/
ContainerTemplate getTemplate() { result = this.getProperty("template") }
/**
* Returns the workloadProfileName property.
*/
StringLiteral getWorkloadProfileName() { result = this.getProperty("workloadProfileName") }
override string toString() { result = "ContainerProperties" }
}
/**
* Represents the configuration object for a container app resource.
*/
class ContainerConfiguration extends Object {
private Properties properties;
/**
* Constructs a Configuration object for the given properties.
*/
ContainerConfiguration() { this = properties.getProperty("configuration") }
/**
* Returns the network ingress configuration.
*/
Network::Ingress getNetworkIngress() { result = this.getProperty("ingress") }
/**
* Returns the secrets defined in the configuration.
*/
ContainerSecret getSecrets() { result = this.getProperty("secrets").(Array).getElements() }
ContainerSecret getSecret(string name) {
exists(ContainerSecret secret |
secret = this.getSecrets() and
secret.getName().getValue() = name
|
result = secret
)
}
/**
* Returns the active revisions mode as a StringLiteral.
*/
StringLiteral getActiveRevisionsMode() { result = this.getProperty("activeRevisionsMode") }
/**
* Returns the active revisions mode as a string.
*/
string activeRevisionsMode() { result = this.getActiveRevisionsMode().getValue() }
/**
* Returns the template property.
*/
Expr getTemplate() { result = this.getProperty("template") }
/**
* Returns the Dapr configuration object, if present.
*
* @return The Dapr configuration expression.
*/
Expr getDapr() { result = this.getProperty("dapr") }
/**
* Returns the identity settings object, if present.
*
* @return The identity settings expression.
*/
Expr getIdentitySettings() { result = this.getProperty("identitySettings") }
/**
* Returns the ingress configuration object, if present.
*
* @return The ingress configuration expression.
*/
Expr getIngress() { result = this.getProperty("ingress") }
/**
* Returns all container registries defined in the configuration.
*
* @return The container registry objects as an array.
*/
ContainerRegistry getRegistries() {
result = this.getProperty("registries").(Array).getElements()
}
/**
* Returns a specific container registry by index.
*
* @param index The index of the registry.
* @return The container registry at the specified index.
*/
ContainerRegistry getRegistry(int index) {
result = this.getProperty("registries").(Array).getElement(index)
}
/**
* Returns the runtime configuration object, if present.
*
* @return The runtime configuration expression.
*/
Expr getRuntime() { result = this.getProperty("runtime") }
/**
* Returns the service configuration object, if present.
*
* @return The service configuration expression.
*/
Expr getService() { result = this.getProperty("service") }
/**
* Returns the target label property, if present.
*
* @return The target label string literal.
*/
StringLiteral getTargetLabel() { result = this.getProperty("targetLabel") }
string toString() { result = "ContainerConfiguration" }
}
/**
* Represents a secret defined in the container app configuration.
*/
class ContainerSecret extends Object {
private ContainerConfiguration configuration;
/**
* Constructs a ContainerSecret for the given configuration.
*/
ContainerSecret() { this = configuration.getProperty("secrets").(Array).getElements() }
/**
* Returns the name of the secret.
*/
StringLiteral getName() { result = this.getProperty("name") }
/**
* Returns the value of the secret.
*/
StringLiteral getValue() { result = this.getProperty("value") }
string toString() { result = "ContainerSecret" }
}
/**
* Represents the template object for a container app resource.
*/
class ContainerTemplate extends Object {
private Properties properties;
/**
* Constructs a ContainerTemplate for the given properties.
*/
ContainerTemplate() { this = properties.getProperty("template") }
/**
* Returns the container app template.
*/
Expr getContainerAppTemplate() { result = this.getProperty("containerAppTemplate") }
/**
* Returns the containers defined in the template.
*/
ContainerApp getContainers() { result = this.getProperty("containers").(Array).getElements() }
/**
* Returns the initContainers defined in the template.
*/
Expr getInitContainers() { result = this.getProperty("initContainers") }
/**
* Returns the revisionSuffix property.
*/
StringLiteral getRevisionSuffix() { result = this.getProperty("revisionSuffix") }
/**
* Returns the scale property.
*/
Expr getScale() { result = this.getProperty("scale") }
/**
* Returns the serviceBinds property.
*/
Expr getServiceBinds() { result = this.getProperty("serviceBinds") }
/**
* Returns the terminationGracePeriodSeconds property.
*/
Expr getTerminationGracePeriodSeconds() {
result = this.getProperty("terminationGracePeriodSeconds")
}
/**
* Returns the volumes property.
*/
Expr getVolumes() { result = this.getProperty("volumes") }
/**
* Returns a specific container by index from the template.
*/
ContainerApp getContainer(int index) {
result = this.getProperty("containers").(Array).getElement(index)
}
string toString() { result = "ContainerTemplate" }
}
/**
* Represents a container defined in the container app template.
*/
class ContainerApp extends Object {
private ContainerTemplate template;
/**
* Constructs a ContainerApp for the given template.
*/
ContainerApp() { this = template.getProperty("containers").(Array).getElements() }
/**
* Returns the parent ContainerTemplate.
*/
ContainerTemplate getContainerTemplate() { result = template }
/**
* Returns the name of the container.
*/
StringLiteral getName() { result = this.getProperty("name") }
/**
* Returns the image of the container.
*/
StringLiteral getImage() { result = this.getProperty("image") }
/**
* Returns the resources object for the container.
*/
ContainerResources getResources() { result = this.getProperty("resources") }
/**
* Returns the environment variables defined for the container.
*/
ContainerEnv getEnvs() { result = this.getProperty("env").(Array).getElements() }
/**
* Returns a specific environment variable by name.
*/
ContainerEnv getEnv(string name) {
exists(ContainerEnv env |
env = this.getEnvs() and
env.getName().getValue() = name
|
result = env
)
}
string toString() { result = "ContainerProperty" }
}
/**
* Represents the resources object for a container.
*/
class ContainerResources extends Object {
private ContainerApp container;
/**
* Constructs a ContainerResources object for the given container.
*/
ContainerResources() { this = container.getProperty("resources") }
/**
* Returns the properties object for the container resource.
*/
ContainerProperties::Properties getContainerProperties() {
result = this.getProperty("properties")
}
/**
* Returns the CPU resource allocation.
*/
Literals getCpu() { result = this.getProperty("cpu") }
/**
* Returns the memory resource allocation.
*/
StringLiteral getMemory() { result = this.getProperty("memory") }
string toString() { result = "ContainerResourceProperties" }
}
/**
* Represents an environment variable defined for a container.
*/
class ContainerEnv extends Object {
private ContainerApp container;
/**
* Constructs a ContainerEnv for the given container.
*/
ContainerEnv() { this = container.getProperty("env").(Array).getElements() }
/**
* Returns the parent ContainerApp.
*/
ContainerApp getContainer() { result = container }
/**
* Returns the name of the environment variable.
*/
StringLiteral getName() { result = this.getProperty("name") }
/**
* Returns the value of the environment variable.
*/
StringLiteral getValue() { result = this.getProperty("value") }
string toString() { result = "ContainerEnv" }
}
class ContainerRegistry extends Object {
private ContainerConfiguration configuration;
/**
* Constructs a ContainerRegistry for the given configuration.
*/
ContainerRegistry() { this = configuration.getProperty("registries").(Array).getElements() }
/**
* Returns the registry server URL.
*/
StringLiteral getServer() { result = this.getProperty("server") }
/**
* Returns the username for the registry.
*/
StringLiteral getUsername() { result = this.getProperty("username") }
/**
* Returns the password for the registry.
*/
StringLiteral getPassword() {
exists(StringLiteral ref | ref = this.getProperty("passwordSecretRef") |
result = configuration.getSecret(ref.getValue()).getValue()
)
or
result = this.getProperty("password")
}
string toString() { result = "ContainerRegistry" }
}
}
}