Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ql/lib/codeql/bicep/Frameworks.qll
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import frameworks.Microsoft.Cache
import frameworks.Microsoft.Compute
import frameworks.Microsoft.Containers
import frameworks.Microsoft.General
import frameworks.Microsoft.ManagedContainers
import frameworks.Microsoft.AKS
import frameworks.Microsoft.Network
import frameworks.Microsoft.Storage
import frameworks.Microsoft.Databases
Expand Down
2 changes: 1 addition & 1 deletion ql/lib/codeql/bicep/ast/Expr.qll
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class MemberExpression extends Expr instanceof MemberExpressionImpl {
/**
* The namespace of the member expression.
*/
Expr getNamespace() { result = MemberExpressionImpl.super.getObject() }
Idents getNamespace() { result = MemberExpressionImpl.super.getObject() }

/**
* The member of the member expression.
Expand Down
4 changes: 4 additions & 0 deletions ql/lib/codeql/bicep/ast/Resources.qll
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ class Resource extends TResource {
exists(StringLiteral sl | sl = resource.getName() | result = sl.getValue())
}

Identifier getIdentifier() {
result = resource.getIdentifier()
}

string getName() {
exists(StringLiteral name |
name = resource.getProperty("name") and
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
private import bicep
private import codeql.bicep.Concepts

module ManagedContainers {
module AKS {
/**
* Represents a Microsoft.ContainerService/managedClusters resource (AKS) in a Bicep file.
* See: https://learn.microsoft.com/en-us/azure/templates/microsoft.containerservice/managedclusters
Expand Down Expand Up @@ -48,117 +48,274 @@ module ManagedContainers {
override string toString() { result = "ManagedContainerResource" }
}

/**
* Module containing property classes for managed AKS (Azure Kubernetes Service) resources.
* Provides access to resource configuration, agent pools, network, API server, and addon profiles.
*/
module ManagedContainerProperties {
/**
* Represents the properties object for a Kubernetes (AKS) resource.
* Provides access to core configuration such as version, DNS prefix, agent pools, network, and more.
*/
class Properties extends Object {
class Properties extends ResourceProperties {
private ManagedContainerResource resource;

/**
* Constructs a Properties object for the given managed AKS resource.
*/
Properties() { this = resource.getProperty("properties") }

/**
* Gets the parent ManagedContainerResource.
*/
ManagedContainerResource getManagedContainerResource() { result = resource }

/**
* Gets the Kubernetes version property.
*/
StringLiteral getKubernetesVersion() { result = this.getProperty("kubernetesVersion") }

string kubernetesVersion() {
result = this.getKubernetesVersion().getValue()
}

/**
* Gets the DNS prefix property.
*/
StringLiteral getDnsPrefix() { result = this.getProperty("dnsPrefix") }

/**
* Gets the agent pool profiles for the cluster.
*/
AgentPoolProfiles getAgentPoolProfiles() {
result = this.getProperty("agentPoolProfiles").(Array).getElements()
}

/**
* Gets the network profile for the cluster.
*/
Network::NetworkProfile getNetworkProfile() { result = this.getProperty("networkProfile") }

/**
* Gets the API server access profile for the cluster.
*/
ApiServerAccessProfile getApiServerAccessProfile() {
result = this.getProperty("apiServerAccessProfile")
}

/**
* Gets the addon profiles for the cluster.
*/
AddonProfiles getAddonProfiles() { result = this.getProperty("addonProfiles") }

/**
* Gets the identity property for the cluster.
*/
Expr getIdentity() { result = this.getProperty("identity") }

/**
* Gets the Linux profile for the cluster.
*/
Expr getLinuxProfile() { result = this.getProperty("linuxProfile") }

/**
* Gets the Windows profile for the cluster.
*/
Expr getWindowsProfile() { result = this.getProperty("windowsProfile") }

/**
* Gets the service principal profile for the cluster.
*/
Expr getServicePrincipalProfile() { result = this.getProperty("servicePrincipalProfile") }

/**
* Gets the AAD profile for the cluster.
*/
Expr getAadProfile() { result = this.getProperty("aadProfile") }

/**
* Gets the auto scaler profile for the cluster.
*/
Expr getAutoScalerProfile() { result = this.getProperty("autoScalerProfile") }

/**
* Gets the HTTP proxy configuration for the cluster.
*/
Expr getHttpProxyConfig() { result = this.getProperty("httpProxyConfig") }

/**
* Gets the pod identity profile for the cluster.
*/
Expr getPodIdentityProfile() { result = this.getProperty("podIdentityProfile") }

/**
* Gets the workload auto scaler profile for the cluster.
*/
Expr getWorkloadAutoScalerProfile() { result = this.getProperty("workloadAutoScalerProfile") }

/**
* Gets the storage profile for the cluster.
*/
Expr getStorageProfile() { result = this.getProperty("storageProfile") }

/**
* Gets the SKU for the cluster.
*/
Sku getSku() { result = this.getProperty("sku") }

/**
* Gets the tags for the cluster.
*/
Tags getTags() { result = this.getProperty("tags") }

string toString() { result = "ManagedContainerProperties" }
override string toString() { result = "ManagedContainerProperties" }
}

/**
* Represents the agent pool profiles for a managed AKS cluster.
* Provides access to properties such as name, VM size, count, OS type, mode, autoscaling, and scaling limits.
*/
class AgentPoolProfiles extends Object {
private Properties properties;

/**
* Constructs an AgentPoolProfiles object for the given properties.
*/
AgentPoolProfiles() {
this = properties.getProperty("agentPoolProfiles").(Array).getElements()
}

/**
* Gets the name of the agent pool.
*/
StringLiteral getName() { result = this.getProperty("name") }

/**
* Gets the VM size for the agent pool.
*/
StringLiteral getVmSize() { result = this.getProperty("vmSize") }

Expr getCount() { result = this.getProperty("count") }
/**
* Gets the node count for the agent pool.
*/
Number getCount() { result = this.getProperty("count") }

/**
* Gets the OS type for the agent pool.
*/
StringLiteral getOsType() { result = this.getProperty("osType") }

/**
* Gets the mode for the agent pool (e.g., System or User).
*/
StringLiteral getMode() { result = this.getProperty("mode") }

/**
* Gets whether autoscaling is enabled for the agent pool.
*/
Boolean getEnableAutoScaling() {
result = this.getProperty("enableAutoScaling")
}

Expr getOsType() { result = this.getProperty("osType") }
/**
* Gets the minimum node count for autoscaling.
*/
Number getMinCount() { result = this.getProperty("minCount") }

Expr getMode() { result = this.getProperty("mode") }
/**
* Gets the maximum node count for autoscaling.
*/
Number getMaxCount() { result = this.getProperty("maxCount") }

string toString() { result = "AgentPoolProfiles" }
}

/**
* Represents the API server access profile for a managed AKS cluster.
* Provides access to properties such as enablePrivateCluster and privateDnsZone.
*/
class ApiServerAccessProfile extends Object {
private Properties properties;

/**
* Constructs an ApiServerAccessProfile object for the given properties.
*/
ApiServerAccessProfile() { this = properties.getProperty("apiServerAccessProfile") }

StringLiteral getEnablePrivateCluster() { result = this.getProperty("enablePrivateCluster") }
/**
* Gets the enablePrivateCluster property.
*/
Boolean getEnablePrivateCluster() { result = this.getProperty("enablePrivateCluster") }

boolean enablePrivateCluster() {
result = this.getEnablePrivateCluster().getBool()
}

/**
* Gets the privateDnsZone property.
*/
StringLiteral getPrivateDnsZone() { result = this.getProperty("privateDnsZone") }

string toString() { result = "ApiServerAccessProfile" }
}

/**
* Represents the addon profiles for a managed AKS cluster.
* Provides access to specific addons such as kubeDashboard and azurePolicy.
*/
class AddonProfiles extends Object {
private Properties properties;

/**
* Constructs an AddonProfiles object for the given properties.
*/
AddonProfiles() { this = properties.getProperty("addonProfiles") }

/**
* Gets the kubeDashboard addon profile.
*/
AddonKubeDashboard getKubeDashboard() { result = this.getProperty("kubeDashboard") }

string toString() { result = "AddonProfiles" }
}

/**
* Represents the kubeDashboard addon profile for a managed AKS cluster.
*/
class AddonKubeDashboard extends Object {
private AddonProfiles profiles;

/**
* Constructs an AddonKubeDashboard object for the given addon profiles.
*/
AddonKubeDashboard() { this = profiles.getProperty("kubeDashboard") }

/**
* Gets the enabled property for the kubeDashboard addon.
*/
Boolean getEnabled() { result = this.getProperty("enabled") }

boolean enabled() {
result = this.getEnabled().getBool()
}

string toString() { result = "AddonKubeDashboard" }
}

/**
* Represents the azurePolicy addon profile for a managed AKS cluster.
*/
class AddonAzurePolicy extends Object {
private AddonProfiles profiles;

/**
* Constructs an AddonAzurePolicy object for the given addon profiles.
*/
AddonAzurePolicy() { this = profiles.getProperty("azurePolicy") }

/**
* Gets the enabled property for the azurePolicy addon.
*/
Boolean getEnabled() { result = this.getProperty("enabled") }

string toString() { result = "AddonAzurePolicy" }
Expand Down
4 changes: 2 additions & 2 deletions ql/lib/codeql/bicep/frameworks/Microsoft/Cache.qll
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ module Cache {
/**
* Represents the properties object for a Redis cache resource.
*/
class Properties extends Object {
class Properties extends ResourceProperties {
private RedisCacheResource redisCache;

/**
Expand All @@ -105,7 +105,7 @@ module Cache {
*/
RedisCacheResource getRedisCacheResource() { result = redisCache }

string toString() { result = "CacheProperties" }
override string toString() { result = "CacheProperties[" + redisCache.getName() + "]" }
}

/**
Expand Down
Loading