Skip to content

feat: Update framework docs #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 11, 2025
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: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ jobs:
--pattern 'extractor-bicep.tar.gz'

tar -zxf extractor-bicep.tar.gz
chmod +x extractor-pack/tools/*.sh
chmod +x extractor-pack/tools/**/*

- name: "Set up Rust"
uses: dtolnay/rust-toolchain@nightly
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/self-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: "CodeQL Bicep Extractor"
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
Expand Down
106 changes: 96 additions & 10 deletions ql/lib/codeql/bicep/frameworks/Microsoft/Compute.qll
Original file line number Diff line number Diff line change
Expand Up @@ -4,126 +4,212 @@ private import bicep
* A resource of type Microsoft.Compute/virtualMachines
*/
module Compute {
/**
* Represents a generic Microsoft.Compute resource.
* Matches any resource of type Microsoft.Compute/*.
*/
class ComputeResource extends Resource {
/**
* Constructs a ComputeResource for any Microsoft.Compute resource type.
*/
ComputeResource() { this.getResourceType().regexpMatch("^Microsoft.Compute/.*") }
}

/**
* A resource of type Microsoft.Compute/virtualMachines
* https://learn.microsoft.com/en-us/azure/templates/microsoft.compute/virtualmachines
* Represents a Microsoft.Compute/virtualMachines resource.
* See: https://learn.microsoft.com/en-us/azure/templates/microsoft.compute/virtualmachines
*/
class VirtualMachines extends ComputeResource {
/**
* Constructs a VirtualMachines resource.
*/
VirtualMachines() {
this.getResourceType().regexpMatch("^Microsoft.Compute/virtualMachines@.*")
}

/**
* Returns a string representation of the VirtualMachines resource.
*/
override string toString() { result = "VirtualMachines Resource" }

/**
* Returns the properties object for this virtual machine.
*/
VirtualMachinesProperties::Properties getProperties() {
result = this.getProperty("properties")
}

/**
* The the hardware network interfaces of the virtual machine
* Returns the hardware network interfaces of the virtual machine.
*/
Network::NetworkInterfaces getNetworkInterfaces() {
result = this.getProperties().getNetworkProfile().getNetworkInterfaces()
}
}

/**
* The properties module for Microsoft.Compute/virtualMachines
* The properties module for Microsoft.Compute/virtualMachines resources.
*/
module VirtualMachinesProperties {
/**
* The properties object for the Microsoft.Compute/virtualMachines type
* The properties object for the Microsoft.Compute/virtualMachines type.
*/
class Properties extends Object {
private VirtualMachines virtualMachines;

/**
* Constructs a Properties object for the given virtual machine.
*/
Properties() { this = virtualMachines.getProperty("properties") }

/**
* Returns the parent VirtualMachines resource.
*/
VirtualMachines getVirtualMachine() { result = virtualMachines }

/**
* Returns the hardware profile object for the virtual machine.
*/
HardwareProfile getHardwareProfile() { result = this.getProperty("hardwareProfile") }

/**
* Returns the network profile object for the virtual machine.
*/
NetworkProfile getNetworkProfile() { result = this.getProperty("networkProfile") }

/**
* Returns the OS profile object for the virtual machine.
*/
OsProfile getOsProfile() { result = this.getProperty("osProfile") }
}

/**
* The hardwareProfile property object for the Microsoft.Compute/virtualMachines type
* The hardwareProfile property object for the Microsoft.Compute/virtualMachines type.
*/
class HardwareProfile extends Object {
private Properties properties;

/**
* Constructs a HardwareProfile object for the given properties.
*/
HardwareProfile() { this = properties.getProperty("hardwareProfile") }

/**
* Returns a string representation of the hardware profile.
*/
string toString() { result = "HardwareProfile" }

/**
* Returns the vmSize property of the hardware profile.
*/
Expr getVmSize() { result = this.getProperty("vmSize") }
}

/**
* A NetworkProfile for the Microsoft.Compute/virtualMachines type
* Represents a network profile for the Microsoft.Compute/virtualMachines type.
*/
class NetworkProfile extends Object {
private Properties properties;

/**
* Constructs a NetworkProfile object for the given properties.
*/
NetworkProfile() { this = properties.getProperty("networkProfile") }

/**
* Returns a string representation of the network profile.
*/
string toString() { result = "NetworkProfile" }

/**
* Returns the network interfaces for the virtual machine.
*/
Network::NetworkInterfaces getNetworkInterfaces() {
result = resolveResource(this.getNetworkInterfacesObject())
}

/**
* Returns the networkInterfaces property as an object array.
*/
private Object getNetworkInterfacesObject() {
result = this.getProperty("networkInterfaces").(Array).getElements()
}
}

/**
* Represents the storage profile for the Microsoft.Compute/virtualMachines type.
*/
class StorageProfile extends Object {
private Properties properties;

/**
* Constructs a StorageProfile object for the given properties.
*/
StorageProfile() { this = properties.getProperty("storageProfile") }

/**
* Returns the image reference for the storage profile.
*/
ImageReference getImageReference() { result = this.getProperty("imageReference") }
}

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

/**
* Constructs an ImageReference object for the given storage profile.
*/
ImageReference() { this = storageProfile.getProperty("imageReference") }

/**
* Returns the publisher property of the image reference.
*/
Expr getPublisher() { result = this.getProperty("publisher") }

/**
* Returns the offer property of the image reference.
*/
Expr getOffer() { result = this.getProperty("offer") }

/**
* Returns the sku property of the image reference.
*/
Expr getSku() { result = this.getProperty("sku") }

/**
* Returns the version property of the image reference.
*/
Expr getVersion() { result = this.getProperty("version") }
}

/**
* The OsProfile object for the Microsoft.Compute/virtualMachines type
* Represents the OS profile for the Microsoft.Compute/virtualMachines type.
*/
class OsProfile extends Object {
private Properties properties;

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

/**
* Returns the computerName property of the OS profile.
*/
Expr getComputerName() { result = this.getProperty("computerName") }

/**
* Returns the adminUsername property of the OS profile.
*/
Expr getAdminUsername() { result = this.getProperty("adminUsername") }

/**
* Returns the adminPassword property of the OS profile.
*/
Expr getAdminPassword() { result = this.getProperty("adminPassword") }
}
}
Expand Down
Loading