Skip to content

Commit c2aaa74

Browse files
committed
feat: Move to using an "Azure Resource"
1 parent b3fbec2 commit c2aaa74

File tree

9 files changed

+23
-47
lines changed

9 files changed

+23
-47
lines changed

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module AKS {
66
* Represents a Microsoft.ContainerService/managedClusters resource (AKS) in a Bicep file.
77
* See: https://learn.microsoft.com/en-us/azure/templates/microsoft.containerservice/managedclusters
88
*/
9-
class ManagedContainerResource extends Resource {
9+
class ManagedContainerResource extends AzureResource {
1010
/**
1111
* Constructs a ManagedContainerResource for Microsoft.ContainerService/managedClusters resources.
1212
*/
@@ -158,11 +158,6 @@ module AKS {
158158
*/
159159
Expr getStorageProfile() { result = this.getProperty("storageProfile") }
160160

161-
/**
162-
* Gets the SKU for the cluster.
163-
*/
164-
Sku getSku() { result = this.getProperty("sku") }
165-
166161
/**
167162
* Gets the tags for the cluster.
168163
*/

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ private import bicep
22
private import codeql.bicep.Concepts
33

44
module Cache {
5-
abstract class CacheResource extends Resource { }
5+
abstract class CacheResource extends AzureResource { }
66

77
/**
88
* Represents an Azure Cache for Redis resource.
@@ -22,11 +22,6 @@ module Cache {
2222
result = this.getProperties().getProperty("redisConfiguration")
2323
}
2424

25-
/**
26-
* Returns the SKU of the Redis cache.
27-
*/
28-
Sku getSku() { result = this.getProperty("sku") }
29-
3025
/**
3126
* Returns the Redis version.
3227
*/

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module Compute {
88
* Represents a generic Microsoft.Compute resource.
99
* Matches any resource of type Microsoft.Compute/*.
1010
*/
11-
class ComputeResource extends Resource {
11+
class ComputeResource extends AzureResource {
1212
/**
1313
* Constructs a ComputeResource for any Microsoft.Compute resource type.
1414
*/

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

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Containers {
55
* Represents a Microsoft.ContainerApp/containerApps resource (2025-02-02-preview).
66
* See: https://learn.microsoft.com/en-us/azure/templates/microsoft.app/containerapps
77
*/
8-
class ContainerResource extends Resource {
8+
class ContainerResource extends AzureResource {
99
/**
1010
* Constructs a ContainerResource for Microsoft.App/containerApps resources.
1111
*/
@@ -73,34 +73,20 @@ module Containers {
7373

7474
Network::CorsPolicy getCorsPolicy() { result = this.getNetworkIngress().getCorsPolicy() }
7575

76-
/**
77-
* Returns the SKU object for the container registry resource.
78-
*/
79-
Sku getSku() { result = this.getProperty("sku") }
80-
81-
Tags getTags() { result = this.getProperty("tags") }
82-
8376
/**
8477
* Returns a string representation of the container app resource.
8578
*/
8679
override string toString() { result = "ContainerResource" }
8780
}
8881

89-
class ContainerRegistry extends Resource {
82+
class ContainerRegistry extends AzureResource {
9083
/**
9184
* Constructs a ContainerRegistry for Microsoft.ContainerRegistry/containerRegistries resources (2025-02-02-preview).
9285
*/
9386
ContainerRegistry() {
9487
this.getResourceType().regexpMatch("^Microsoft.ContainerRegistry/registries@.*$")
9588
}
9689

97-
/**
98-
* Returns the SKU object for the container registry resource.
99-
*/
100-
Sku getSku() { result = this.getProperty("sku") }
101-
102-
Tags getTags() { result = this.getProperty("tags") }
103-
10490
override string toString() { result = "ContainerRegistry" }
10591
}
10692

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module Databases {
66
* Base class for all database resources in Azure.
77
* Provides common properties and methods for Azure database resources.
88
*/
9-
abstract class DatabaseResource extends Resource {
9+
abstract class DatabaseResource extends AzureResource {
1010
/**
1111
* Returns the type of the database resource (e.g., sql, postgresql, etc).
1212
*/

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
private import bicep
22

3+
abstract class AzureResource extends Resource {
4+
string resourceLocation() {
5+
result = this.getProperty("location").(StringLiteral).getValue()
6+
}
7+
8+
Sku getSku() { result = this.getProperty("sku") }
9+
10+
Tags getTags() { result = this.getProperty("tags") }
11+
}
12+
313
abstract class ResourceProperties extends Object {
414
string toString() {
515
result = super.toString()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module KeyVault {
66
* Represents a Microsoft.KeyVault resource in a Bicep file.
77
* Provides access to Key Vault properties, access policies, and network ACLs.
88
*/
9-
class VaultResource extends Resource {
9+
class VaultResource extends AzureResource {
1010
/**
1111
* Constructs a VaultResource for any Microsoft.KeyVault resource type.
1212
* Matches resources with type starting with "Microsoft.KeyVault/".

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Network {
55
* Represents a generic Microsoft.Network resource.
66
* Matches any resource of type Microsoft.Network/*.
77
*/
8-
class NetworkResource extends Resource {
8+
class NetworkResource extends AzureResource {
99
/**
1010
* Constructs a NetworkResource for any Microsoft.Network resource type.
1111
*/
@@ -103,7 +103,7 @@ module Network {
103103
/**
104104
* Represents a Microsoft.Network/virtualNetworks/subnets resource.
105105
*/
106-
class VirtualNetworkSubnets extends Resource {
106+
class VirtualNetworkSubnets extends AzureResource {
107107
/**
108108
* Constructs a VirtualNetworkSubnets resource.
109109
*/

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

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module Storage {
66
* Provides access to storage account properties, kind, network ACLs, and SKU.
77
* See: https://learn.microsoft.com/en-us/azure/templates/microsoft.storage/storageaccounts
88
*/
9-
class StorageAccounts extends Resource {
9+
class StorageAccounts extends AzureResource {
1010
/**
1111
* Constructs a StorageAccounts resource.
1212
*/
@@ -33,11 +33,6 @@ module Storage {
3333
*/
3434
Network::NetworkAcl getNetworkAcls() { result = this.getProperties().getNetworkAcls() }
3535

36-
/**
37-
* Gets the SKU for the storage account.
38-
*/
39-
Sku getSku() { result = this.getProperty("sku") }
40-
4136
override string toString() { result = "StorageAccount[" + this.getName() + "]" }
4237
}
4338

@@ -46,7 +41,7 @@ module Storage {
4641
* Provides access to disk properties, encryption, zones, and disk pools.
4742
* See: https://learn.microsoft.com/en-us/azure/templates/microsoft.compute/disks
4843
*/
49-
class Disks extends Resource {
44+
class Disks extends AzureResource {
5045
/**
5146
* Constructs a Disks resource.
5247
*/
@@ -107,7 +102,7 @@ module Storage {
107102
* Provides access to disk pool properties, attached disks, and SKU.
108103
* See: https://learn.microsoft.com/en-us/azure/templates/microsoft.storagepool/diskpools
109104
*/
110-
class DiskPools extends Resource {
105+
class DiskPools extends AzureResource {
111106
/**
112107
* Constructs a DiskPools resource.
113108
*/
@@ -130,11 +125,6 @@ module Storage {
130125
)
131126
}
132127

133-
/**
134-
* Gets the SKU for the disk pool.
135-
*/
136-
Sku getSku() { result = this.getProperty("sku") }
137-
138128
override string toString() { result = "DiskPools" }
139129
}
140130

@@ -143,7 +133,7 @@ module Storage {
143133
* Provides access to container properties and public access settings.
144134
* See: https://learn.microsoft.com/en-us/azure/templates/microsoft.storage/storageaccounts/blobservices/containers
145135
*/
146-
class BlobServiceContainers extends Resource {
136+
class BlobServiceContainers extends AzureResource {
147137
/**
148138
* Constructs a BlobServiceContainers resource.
149139
*/

0 commit comments

Comments
 (0)