-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainers.qll
More file actions
296 lines (241 loc) · 8.46 KB
/
Containers.qll
File metadata and controls
296 lines (241 loc) · 8.46 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
private import bicep
module Containers {
/**
* Represents a Microsoft.ContainerApp/containerApps resource.
* See: https://learn.microsoft.com/en-us/azure/templates/microsoft.app/containerapps
*/
class ContainerResource extends Resource {
/**
* Constructs a ContainerResource for Microsoft.App/containerApps resources.
*/
ContainerResource() { this.getResourceType().regexpMatch("^Microsoft.App/containerApps@.*") }
/**
* 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" }
}
module ContainerProperties {
/**
* Represents the properties object for a container app resource.
*/
class Properties extends Object {
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 template property.
*/
ContainerTemplate getTemplate() { result = this.getProperty("template") }
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() }
/**
* 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") }
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 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" }
}
}
}