Skip to content

Commit 305de44

Browse files
committed
feat(frameworks): Add Microsoft framework support
1 parent e09ee55 commit 305de44

File tree

3 files changed

+302
-0
lines changed

3 files changed

+302
-0
lines changed
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
private import bicep
2+
private import Network
3+
4+
/**
5+
* A resource of type Microsoft.Compute/virtualMachines
6+
*/
7+
module Compute {
8+
class ComputeResource extends Resource {
9+
ComputeResource() { this.getResourceType().regexpMatch("^Microsoft.Compute/.*") }
10+
}
11+
12+
/**
13+
* A resource of type Microsoft.Compute/virtualMachines
14+
* https://learn.microsoft.com/en-us/azure/templates/microsoft.compute/virtualmachines
15+
*/
16+
class VirtualMachines extends ComputeResource {
17+
VirtualMachines() {
18+
this.getResourceType().regexpMatch("^Microsoft.Compute/virtualMachines@.*")
19+
}
20+
21+
override string toString() { result = "VirtualMachines Resource" }
22+
23+
VirtualMachinesProperties::Properties getProperties() {
24+
result = this.getProperty("properties")
25+
}
26+
27+
/**
28+
* The the hardware network interfaces of the virtual machine
29+
*/
30+
Network::NetworkInterfaces getNetworkInterfaces() {
31+
result = this.getProperties().getNetworkProfile().getNetworkInterfaces()
32+
}
33+
}
34+
35+
/**
36+
* The properties module for Microsoft.Compute/virtualMachines
37+
*/
38+
module VirtualMachinesProperties {
39+
/**
40+
* The properties object for the Microsoft.Compute/virtualMachines type
41+
*/
42+
class Properties extends Object {
43+
private VirtualMachines virtualMachines;
44+
45+
Properties() { this = virtualMachines.getProperty("properties") }
46+
47+
VirtualMachines getVirtualMachine() { result = virtualMachines }
48+
49+
HardwareProfile getHardwareProfile() { result = this.getProperty("hardwareProfile") }
50+
51+
NetworkProfile getNetworkProfile() { result = this.getProperty("networkProfile") }
52+
53+
OsProfile getOsProfile() { result = this.getProperty("osProfile") }
54+
}
55+
56+
/**
57+
* The hardwareProfile property object for the Microsoft.Compute/virtualMachines type
58+
*/
59+
class HardwareProfile extends Object {
60+
private Properties properties;
61+
62+
HardwareProfile() { this = properties.getProperty("hardwareProfile") }
63+
64+
string toString() { result = "HardwareProfile" }
65+
66+
Expr getVmSize() { result = this.getProperty("vmSize") }
67+
}
68+
69+
/**
70+
* A NetworkProfile for the Microsoft.Compute/virtualMachines type
71+
*/
72+
class NetworkProfile extends Object {
73+
private Properties properties;
74+
75+
NetworkProfile() { this = properties.getProperty("networkProfile") }
76+
77+
string toString() { result = "NetworkProfile" }
78+
79+
Network::NetworkInterfaces getNetworkInterfaces() {
80+
result = resolveResource(this.getNetworkInterfacesObject())
81+
}
82+
83+
private Object getNetworkInterfacesObject() {
84+
result = this.getProperty("networkInterfaces").(Array).getElements()
85+
}
86+
}
87+
88+
/**
89+
*/
90+
class StorageProfile extends Object {
91+
private Properties properties;
92+
93+
StorageProfile() { this = properties.getProperty("storageProfile") }
94+
95+
ImageReference getImageReference() { result = this.getProperty("imageReference") }
96+
}
97+
98+
/**
99+
* A ImageReference for the Microsoft.Compute/virtualMachines type
100+
* https://learn.microsoft.com/en-us/azure/templates/microsoft.compute/virtualmachines?pivots=deployment-language-bicep#imagereference
101+
*/
102+
class ImageReference extends Object {
103+
private StorageProfile storageProfile;
104+
105+
ImageReference() { this = storageProfile.getProperty("imageReference") }
106+
107+
Expr getPublisher() { result = this.getProperty("publisher") }
108+
109+
Expr getOffer() { result = this.getProperty("offer") }
110+
111+
Expr getSku() { result = this.getProperty("sku") }
112+
113+
Expr getVersion() { result = this.getProperty("version") }
114+
}
115+
116+
/**
117+
* The OsProfile object for the Microsoft.Compute/virtualMachines type
118+
*/
119+
class OsProfile extends Object {
120+
private Properties properties;
121+
122+
OsProfile() { this = properties.getProperty("osProfile") }
123+
124+
Expr getComputerName() { result = this.getProperty("computerName") }
125+
126+
Expr getAdminUsername() { result = this.getProperty("adminUsername") }
127+
128+
Expr getAdminPassword() { result = this.getProperty("adminPassword") }
129+
}
130+
}
131+
}
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
private import bicep
2+
3+
module Network {
4+
/**
5+
* A resource of type Microsoft.Network
6+
*/
7+
class NetworkResource extends Resource {
8+
NetworkResource() { this.getResourceType().regexpMatch("^Microsoft.Network/.*") }
9+
}
10+
11+
/**
12+
* A resource of type Microsoft.Network/networkInterfaces
13+
*/
14+
class NetworkInterfaces extends NetworkResource {
15+
NetworkInterfaces() {
16+
this.getResourceType().regexpMatch("^Microsoft.Network/networkInterfaces@.*")
17+
}
18+
19+
override string toString() { result = "NetworkInterfaces Resource" }
20+
21+
NetworkInterfaceProperties::Properties getProperties() {
22+
result = this.getProperty("properties")
23+
}
24+
}
25+
26+
/**
27+
* A module for all properties of Microsoft.Network/networkInterfaces
28+
*/
29+
module NetworkInterfaceProperties {
30+
/**
31+
* The properties object for the Microsoft.Network/networkInterfaces type
32+
*/
33+
class Properties extends Object {
34+
private NetworkInterfaces networkInterfaces;
35+
36+
Properties() { this = networkInterfaces.getProperty("properties") }
37+
38+
IpConfiguration getIpConfigurations() {
39+
result = this.getProperty("ipConfigurations").(Array).getElements()
40+
}
41+
}
42+
43+
/**
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
46+
*/
47+
class IpConfiguration extends Object {
48+
private Properties properties;
49+
50+
IpConfiguration() { this = properties.getProperty("ipConfigurations").(Array).getElements() }
51+
52+
string getName() { result = this.getProperty("name").(StringLiteral).getValue() }
53+
}
54+
}
55+
56+
/**
57+
* A resource of type Microsoft.Network/virtualNetworks
58+
*/
59+
class VirtualNetworks extends NetworkResource {
60+
VirtualNetworks() {
61+
this.getResourceType().regexpMatch("^Microsoft.Network/virtualNetworks@.*")
62+
}
63+
64+
override string toString() { result = "VirtualNetworks Resource" }
65+
66+
/**
67+
* Get the properties object for the Microsoft.Network/virtualNetworks type
68+
*/
69+
VirtualNetworkProperties::Properties getProperties() { result = this.getProperty("properties") }
70+
}
71+
72+
/**
73+
* A resource of type Microsoft.Network/virtualNetworks/subnets
74+
*/
75+
class VirtualNetworkSubnets extends Resource {
76+
VirtualNetworkSubnets() {
77+
this.getResourceType().regexpMatch("^Microsoft.Network/virtualNetworks/subnets@.*")
78+
}
79+
}
80+
81+
module VirtualNetworkProperties {
82+
/**
83+
* The properties object for the Microsoft.Network/virtualNetworks/subnets type
84+
*/
85+
class Properties extends Object {
86+
private VirtualNetworkSubnets virtualNetworkSubnets;
87+
88+
Properties() { this = virtualNetworkSubnets.getProperty("properties") }
89+
90+
AddressSpace getAddressSpace() { result = this.getProperty("addressSpace") }
91+
92+
boolean getEnableDdosProtection() {
93+
result = this.getProperty("enableDdosProtection").(Boolean).getBool()
94+
}
95+
96+
boolean getEnableVmProtection() {
97+
result = this.getProperty("enableVmProtection").(Boolean).getBool()
98+
}
99+
}
100+
101+
/**
102+
* An AddressSpace for the Microsoft.Network/virtualNetworks type
103+
*/
104+
class AddressSpace extends Object {
105+
private Properties properties;
106+
107+
AddressSpace() { this = properties.getProperty("addressSpace") }
108+
109+
string getAddressPrefixes() {
110+
result =
111+
this.getProperty("addressPrefixes").(Array).getElements().(StringLiteral).getValue()
112+
}
113+
}
114+
}
115+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
private import bicep
2+
3+
module Storage {
4+
class StorageAccounts extends Resource {
5+
StorageAccounts() {
6+
this.getResourceType().regexpMatch("^Microsoft.Storage/storageAccounts@.*")
7+
}
8+
9+
Expr getKind() { result = this.getProperty("kind") }
10+
}
11+
12+
class StorageAccountsProperties extends Object {
13+
private StorageAccounts storageAccounts;
14+
15+
StorageAccountsProperties() { this = storageAccounts.getProperty("properties") }
16+
17+
boolean getSupportsHttpsTrafficOnly() {
18+
result = this.getProperty("supportsHttpsTrafficOnly").(Boolean).getBool()
19+
}
20+
}
21+
22+
/**
23+
* A resource of type Microsoft.Compute/disks
24+
*/
25+
class Disks extends Resource {
26+
Disks() { this.getResourceType().regexpMatch("^Microsoft.Compute/disks@.*") }
27+
}
28+
29+
/**
30+
* The Disk Properties object for the Microsoft.Compute/disks type
31+
*/
32+
class DisksProperties extends Object {
33+
private Disks disks;
34+
35+
DisksProperties() { this = disks.getProperty("properties") }
36+
37+
Object getEncryptionSettings() { result = this.getProperty("encryptionSettingsCollection") }
38+
39+
boolean getEncryptionEnabled() {
40+
result = this.getEncryptionSettings().getProperty("enabled").(Boolean).getBool()
41+
}
42+
}
43+
44+
class BlobServiceContainers extends Resource {
45+
BlobServiceContainers() {
46+
this.getResourceType()
47+
.regexpMatch("^Microsoft.Storage/storageAccounts/blobServices/containers@.*")
48+
}
49+
50+
Object getProperties() { result = this.getProperty("properties") }
51+
52+
string getPublicAccess() {
53+
result = this.getProperties().getProperty("publicAccess").(StringLiteral).getValue()
54+
}
55+
}
56+
}

0 commit comments

Comments
 (0)