-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGeneral.qll
More file actions
108 lines (93 loc) · 3.1 KB
/
General.qll
File metadata and controls
108 lines (93 loc) · 3.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
/**
* General resource property helpers for Azure resources in Bicep.
*
* Provides common property accessors for location, SKU, and tags.
*
* Classes:
* - AzureResource: Abstract base for Azure resources, provides access to location, SKU, and tags.
* - ResourceProperties: Abstract base for resource property objects.
* - Sku: Represents the SKU of a resource, with access to name and tier.
* - Tags: Represents the tags of a resource, with access to tag values by key.
*/
private import bicep
/**
* Abstract base class for Azure resources in Bicep.
* Provides accessors for common resource properties such as location, SKU, and tags.
*/
abstract class AzureResource extends Resource {
/**
* Gets the location of the resource as a string value.
* @return The Azure region/location of the resource (e.g., "eastus").
*/
string resourceLocation() { result = this.getProperty("location").(StringLiteral).getValue() }
/**
* Gets the SKU object for the resource.
* @return The SKU object representing the resource's SKU.
*/
Sku getSku() { result = this.getProperty("sku") }
/**
* Gets the Tags object for the resource.
* @return The Tags object representing the resource's tags.
*/
Tags getTags() { result = this.getProperty("tags") }
}
/**
* Abstract base class for resource property objects.
* Can be extended to provide additional property accessors for specific resource types.
*/
abstract class ResourceProperties extends Object {
/**
* Returns a string representation of the resource properties object.
*/
string toString() { result = super.toString() }
}
/**
* Represents the SKU of an Azure resource.
* Provides access to the SKU name and tier.
*/
class Sku extends Object {
private Resource resource;
/**
* Constructs a Sku object for the given resource.
*/
Sku() { this = resource.getProperty("sku") }
/**
* Gets the SKU name as a StringLiteral.
* @return The SKU name property as a StringLiteral.
*/
StringLiteral getName() { result = this.getProperty("name") }
/**
* Returns the SKU name (e.g., Basic, Standard, Premium).
* @return The SKU name as a string.
*/
string name() { result = this.getName().getValue() }
/**
* Gets the SKU tier as a StringLiteral.
* @return The SKU tier property as a StringLiteral.
*/
StringLiteral getTier() { result = this.getProperty("tier") }
/**
* Returns the SKU tier (e.g., Basic, Standard, Premium).
* @return The SKU tier as a string.
*/
string tier() { result = this.getTier().getValue() }
string toString() { result = "SKU" }
}
/**
* Represents the tags of an Azure resource.
* Provides access to tag values by key.
*/
class Tags extends Object {
private Resource resource;
/**
* Constructs a Tags object for the given resource.
*/
Tags() { this = resource.getProperty("tags") }
/**
* Gets the value of a tag by its key.
* @param key The tag key to look up.
* @return The value of the tag as a Literals object, or undefined if not present.
*/
Literals getTag(string key) { result = this.getProperty(key) }
string toString() { result = "Tags" }
}