Skip to content

Commit 6b4efa5

Browse files
committed
feat: Update framework docs
1 parent ce3e8be commit 6b4efa5

File tree

3 files changed

+175
-23
lines changed

3 files changed

+175
-23
lines changed

ql/lib/codeql/bicep/frameworks/Microsoft/Compute.qll

Lines changed: 96 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,126 +4,212 @@ private import bicep
44
* A resource of type Microsoft.Compute/virtualMachines
55
*/
66
module Compute {
7+
/**
8+
* Represents a generic Microsoft.Compute resource.
9+
* Matches any resource of type Microsoft.Compute/*.
10+
*/
711
class ComputeResource extends Resource {
12+
/**
13+
* Constructs a ComputeResource for any Microsoft.Compute resource type.
14+
*/
815
ComputeResource() { this.getResourceType().regexpMatch("^Microsoft.Compute/.*") }
916
}
1017

1118
/**
12-
* A resource of type Microsoft.Compute/virtualMachines
13-
* https://learn.microsoft.com/en-us/azure/templates/microsoft.compute/virtualmachines
19+
* Represents a Microsoft.Compute/virtualMachines resource.
20+
* See: https://learn.microsoft.com/en-us/azure/templates/microsoft.compute/virtualmachines
1421
*/
1522
class VirtualMachines extends ComputeResource {
23+
/**
24+
* Constructs a VirtualMachines resource.
25+
*/
1626
VirtualMachines() {
1727
this.getResourceType().regexpMatch("^Microsoft.Compute/virtualMachines@.*")
1828
}
1929

30+
/**
31+
* Returns a string representation of the VirtualMachines resource.
32+
*/
2033
override string toString() { result = "VirtualMachines Resource" }
2134

35+
/**
36+
* Returns the properties object for this virtual machine.
37+
*/
2238
VirtualMachinesProperties::Properties getProperties() {
2339
result = this.getProperty("properties")
2440
}
2541

2642
/**
27-
* The the hardware network interfaces of the virtual machine
43+
* Returns the hardware network interfaces of the virtual machine.
2844
*/
2945
Network::NetworkInterfaces getNetworkInterfaces() {
3046
result = this.getProperties().getNetworkProfile().getNetworkInterfaces()
3147
}
3248
}
3349

3450
/**
35-
* The properties module for Microsoft.Compute/virtualMachines
51+
* The properties module for Microsoft.Compute/virtualMachines resources.
3652
*/
3753
module VirtualMachinesProperties {
3854
/**
39-
* The properties object for the Microsoft.Compute/virtualMachines type
55+
* The properties object for the Microsoft.Compute/virtualMachines type.
4056
*/
4157
class Properties extends Object {
4258
private VirtualMachines virtualMachines;
4359

60+
/**
61+
* Constructs a Properties object for the given virtual machine.
62+
*/
4463
Properties() { this = virtualMachines.getProperty("properties") }
4564

65+
/**
66+
* Returns the parent VirtualMachines resource.
67+
*/
4668
VirtualMachines getVirtualMachine() { result = virtualMachines }
4769

70+
/**
71+
* Returns the hardware profile object for the virtual machine.
72+
*/
4873
HardwareProfile getHardwareProfile() { result = this.getProperty("hardwareProfile") }
4974

75+
/**
76+
* Returns the network profile object for the virtual machine.
77+
*/
5078
NetworkProfile getNetworkProfile() { result = this.getProperty("networkProfile") }
5179

80+
/**
81+
* Returns the OS profile object for the virtual machine.
82+
*/
5283
OsProfile getOsProfile() { result = this.getProperty("osProfile") }
5384
}
5485

5586
/**
56-
* The hardwareProfile property object for the Microsoft.Compute/virtualMachines type
87+
* The hardwareProfile property object for the Microsoft.Compute/virtualMachines type.
5788
*/
5889
class HardwareProfile extends Object {
5990
private Properties properties;
6091

92+
/**
93+
* Constructs a HardwareProfile object for the given properties.
94+
*/
6195
HardwareProfile() { this = properties.getProperty("hardwareProfile") }
6296

97+
/**
98+
* Returns a string representation of the hardware profile.
99+
*/
63100
string toString() { result = "HardwareProfile" }
64101

102+
/**
103+
* Returns the vmSize property of the hardware profile.
104+
*/
65105
Expr getVmSize() { result = this.getProperty("vmSize") }
66106
}
67107

68108
/**
69-
* A NetworkProfile for the Microsoft.Compute/virtualMachines type
109+
* Represents a network profile for the Microsoft.Compute/virtualMachines type.
70110
*/
71111
class NetworkProfile extends Object {
72112
private Properties properties;
73113

114+
/**
115+
* Constructs a NetworkProfile object for the given properties.
116+
*/
74117
NetworkProfile() { this = properties.getProperty("networkProfile") }
75118

119+
/**
120+
* Returns a string representation of the network profile.
121+
*/
76122
string toString() { result = "NetworkProfile" }
77123

124+
/**
125+
* Returns the network interfaces for the virtual machine.
126+
*/
78127
Network::NetworkInterfaces getNetworkInterfaces() {
79128
result = resolveResource(this.getNetworkInterfacesObject())
80129
}
81130

131+
/**
132+
* Returns the networkInterfaces property as an object array.
133+
*/
82134
private Object getNetworkInterfacesObject() {
83135
result = this.getProperty("networkInterfaces").(Array).getElements()
84136
}
85137
}
86138

87139
/**
140+
* Represents the storage profile for the Microsoft.Compute/virtualMachines type.
88141
*/
89142
class StorageProfile extends Object {
90143
private Properties properties;
91144

145+
/**
146+
* Constructs a StorageProfile object for the given properties.
147+
*/
92148
StorageProfile() { this = properties.getProperty("storageProfile") }
93149

150+
/**
151+
* Returns the image reference for the storage profile.
152+
*/
94153
ImageReference getImageReference() { result = this.getProperty("imageReference") }
95154
}
96155

97156
/**
98-
* A ImageReference for the Microsoft.Compute/virtualMachines type
99-
* https://learn.microsoft.com/en-us/azure/templates/microsoft.compute/virtualmachines?pivots=deployment-language-bicep#imagereference
157+
* Represents an image reference for the Microsoft.Compute/virtualMachines type.
158+
* See: https://learn.microsoft.com/en-us/azure/templates/microsoft.compute/virtualmachines?pivots=deployment-language-bicep#imagereference
100159
*/
101160
class ImageReference extends Object {
102161
private StorageProfile storageProfile;
103162

163+
/**
164+
* Constructs an ImageReference object for the given storage profile.
165+
*/
104166
ImageReference() { this = storageProfile.getProperty("imageReference") }
105167

168+
/**
169+
* Returns the publisher property of the image reference.
170+
*/
106171
Expr getPublisher() { result = this.getProperty("publisher") }
107172

173+
/**
174+
* Returns the offer property of the image reference.
175+
*/
108176
Expr getOffer() { result = this.getProperty("offer") }
109177

178+
/**
179+
* Returns the sku property of the image reference.
180+
*/
110181
Expr getSku() { result = this.getProperty("sku") }
111182

183+
/**
184+
* Returns the version property of the image reference.
185+
*/
112186
Expr getVersion() { result = this.getProperty("version") }
113187
}
114188

115189
/**
116-
* The OsProfile object for the Microsoft.Compute/virtualMachines type
190+
* Represents the OS profile for the Microsoft.Compute/virtualMachines type.
117191
*/
118192
class OsProfile extends Object {
119193
private Properties properties;
120194

195+
/**
196+
* Constructs an OsProfile object for the given properties.
197+
*/
121198
OsProfile() { this = properties.getProperty("osProfile") }
122199

200+
/**
201+
* Returns the computerName property of the OS profile.
202+
*/
123203
Expr getComputerName() { result = this.getProperty("computerName") }
124204

205+
/**
206+
* Returns the adminUsername property of the OS profile.
207+
*/
125208
Expr getAdminUsername() { result = this.getProperty("adminUsername") }
126209

210+
/**
211+
* Returns the adminPassword property of the OS profile.
212+
*/
127213
Expr getAdminPassword() { result = this.getProperty("adminPassword") }
128214
}
129215
}

ql/lib/codeql/bicep/frameworks/Microsoft/Network.qll

Lines changed: 63 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,110 +2,162 @@ private import bicep
22

33
module Network {
44
/**
5-
* A resource of type Microsoft.Network
5+
* Represents a generic Microsoft.Network resource.
6+
* Matches any resource of type Microsoft.Network/*.
67
*/
78
class NetworkResource extends Resource {
9+
/**
10+
* Constructs a NetworkResource for any Microsoft.Network resource type.
11+
*/
812
NetworkResource() { this.getResourceType().regexpMatch("^Microsoft.Network/.*") }
913
}
1014

1115
/**
12-
* A resource of type Microsoft.Network/networkInterfaces
16+
* Represents a Microsoft.Network/networkInterfaces resource.
1317
*/
1418
class NetworkInterfaces extends NetworkResource {
19+
/**
20+
* Constructs a NetworkInterfaces resource.
21+
*/
1522
NetworkInterfaces() {
1623
this.getResourceType().regexpMatch("^Microsoft.Network/networkInterfaces@.*")
1724
}
1825

26+
/**
27+
* Returns a string representation of the NetworkInterfaces resource.
28+
*/
1929
override string toString() { result = "NetworkInterfaces Resource" }
2030

31+
/**
32+
* Returns the properties object for this network interface.
33+
*/
2134
NetworkInterfaceProperties::Properties getProperties() {
2235
result = this.getProperty("properties")
2336
}
2437
}
2538

2639
/**
27-
* A module for all properties of Microsoft.Network/networkInterfaces
40+
* A module for all properties of Microsoft.Network/networkInterfaces resources.
2841
*/
2942
module NetworkInterfaceProperties {
3043
/**
31-
* The properties object for the Microsoft.Network/networkInterfaces type
44+
* The properties object for the Microsoft.Network/networkInterfaces type.
3245
*/
3346
class Properties extends Object {
3447
private NetworkInterfaces networkInterfaces;
3548

49+
/**
50+
* Constructs a Properties object for the given network interface.
51+
*/
3652
Properties() { this = networkInterfaces.getProperty("properties") }
3753

54+
/**
55+
* Returns the ipConfigurations property as an array of IpConfiguration objects.
56+
*/
3857
IpConfiguration getIpConfigurations() {
3958
result = this.getProperty("ipConfigurations").(Array).getElements()
4059
}
4160
}
4261

4362
/**
44-
* An IpConfiguration for the Microsoft.Network/networkInterfaces type
45-
* https://learn.microsoft.com/en-us/azure/templates/microsoft.compute/virtualmachines?pivots=deployment-language-bicep#virtualmachinenetworkinterfaceipconfigurationproperties
63+
* Represents an IpConfiguration for the Microsoft.Network/networkInterfaces type.
64+
* See: https://learn.microsoft.com/en-us/azure/templates/microsoft.compute/virtualmachines?pivots=deployment-language-bicep#virtualmachinenetworkinterfaceipconfigurationproperties
4665
*/
4766
class IpConfiguration extends Object {
4867
private Properties properties;
4968

69+
/**
70+
* Constructs an IpConfiguration object for the given properties.
71+
*/
5072
IpConfiguration() { this = properties.getProperty("ipConfigurations").(Array).getElements() }
5173

74+
/**
75+
* Returns the name property of the IpConfiguration.
76+
*/
5277
string getName() { result = this.getProperty("name").(StringLiteral).getValue() }
5378
}
5479
}
5580

5681
/**
57-
* A resource of type Microsoft.Network/virtualNetworks
82+
* Represents a Microsoft.Network/virtualNetworks resource.
5883
*/
5984
class VirtualNetworks extends NetworkResource {
85+
/**
86+
* Constructs a VirtualNetworks resource.
87+
*/
6088
VirtualNetworks() {
6189
this.getResourceType().regexpMatch("^Microsoft.Network/virtualNetworks@.*")
6290
}
6391

92+
/**
93+
* Returns a string representation of the VirtualNetworks resource.
94+
*/
6495
override string toString() { result = "VirtualNetworks Resource" }
6596

6697
/**
67-
* Get the properties object for the Microsoft.Network/virtualNetworks type
98+
* Returns the properties object for the Microsoft.Network/virtualNetworks type.
6899
*/
69100
VirtualNetworkProperties::Properties getProperties() { result = this.getProperty("properties") }
70101
}
71102

72103
/**
73-
* A resource of type Microsoft.Network/virtualNetworks/subnets
104+
* Represents a Microsoft.Network/virtualNetworks/subnets resource.
74105
*/
75106
class VirtualNetworkSubnets extends Resource {
107+
/**
108+
* Constructs a VirtualNetworkSubnets resource.
109+
*/
76110
VirtualNetworkSubnets() {
77111
this.getResourceType().regexpMatch("^Microsoft.Network/virtualNetworks/subnets@.*")
78112
}
79113
}
80114

81115
module VirtualNetworkProperties {
82116
/**
83-
* The properties object for the Microsoft.Network/virtualNetworks/subnets type
117+
* The properties object for the Microsoft.Network/virtualNetworks/subnets type.
84118
*/
85119
class Properties extends Object {
86120
private VirtualNetworkSubnets virtualNetworkSubnets;
87121

122+
/**
123+
* Constructs a Properties object for the given subnet.
124+
*/
88125
Properties() { this = virtualNetworkSubnets.getProperty("properties") }
89126

127+
/**
128+
* Returns the address space object for the subnet.
129+
*/
90130
AddressSpace getAddressSpace() { result = this.getProperty("addressSpace") }
91131

132+
/**
133+
* Returns true if DDoS protection is enabled for the subnet.
134+
*/
92135
boolean getEnableDdosProtection() {
93136
result = this.getProperty("enableDdosProtection").(Boolean).getBool()
94137
}
95138

139+
/**
140+
* Returns true if VM protection is enabled for the subnet.
141+
*/
96142
boolean getEnableVmProtection() {
97143
result = this.getProperty("enableVmProtection").(Boolean).getBool()
98144
}
99145
}
100146

101147
/**
102-
* An AddressSpace for the Microsoft.Network/virtualNetworks type
148+
* Represents an AddressSpace for the Microsoft.Network/virtualNetworks type.
103149
*/
104150
class AddressSpace extends Object {
105151
private Properties properties;
106152

153+
/**
154+
* Constructs an AddressSpace object for the given properties.
155+
*/
107156
AddressSpace() { this = properties.getProperty("addressSpace") }
108157

158+
/**
159+
* Returns the addressPrefixes property as a string value.
160+
*/
109161
string getAddressPrefixes() {
110162
result =
111163
this.getProperty("addressPrefixes").(Array).getElements().(StringLiteral).getValue()

0 commit comments

Comments
 (0)