Skip to content
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

Hotifx: Update TL as Default feature to further restrict it #23297

Merged
merged 13 commits into from
Nov 8, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ private bool shouldGuestAttestationExtBeInstalled(VirtualMachineScaleSet vmssPar
{
if (this.DisableIntegrityMonitoring != true &&
vmssParameters != null &&
vmssParameters.OrchestrationMode != "Flexible" &&
vmssParameters.VirtualMachineProfile != null &&
vmssParameters.VirtualMachineProfile.SecurityProfile != null &&
vmssParameters.VirtualMachineProfile.SecurityProfile.SecurityType?.ToLower() == ConstantValues.TrustedLaunchSecurityType &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,12 @@ private async Task<ResourceConfig<VirtualMachineScaleSet>> SimpleParameterSetOrc

var hostGroup = resourceGroup.CreateDedicatedHostGroupSubResourceFunc(_cmdlet.HostGroupId);

if (!_cmdlet.IsParameterBound(c => c.SystemAssignedIdentity)
&& _cmdlet.SystemAssignedIdentity == true)
{
_cmdlet.SystemAssignedIdentity = false;
}

return resourceGroup.CreateVirtualMachineScaleSetConfigOrchestrationModeFlexible(
name: _cmdlet.VMScaleSetName,
subnet: subnet,
Expand Down Expand Up @@ -737,7 +743,8 @@ async Task SimpleParameterSetExecuteCmdlet(IAsyncCmdlet asyncCmdlet)
asyncCmdlet.WriteObject(psObject);
}

if (shouldGuestAttestationExtBeInstalledSimple())
if (shouldGuestAttestationExtBeInstalledSimple()
&& this.SystemAssignedIdentity == true)
{
string extensionNameGA = "GuestAttestation";
var extensionDirect = new VirtualMachineScaleSetExtension();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,11 @@ public class NewAzureVMCommand : VirtualMachineBaseCmdlet
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = "This flag disables the default behavior to install the Guest Attestation extension to the virtual machine if: 1) SecurityType is TrustedLaunch, 2) SecureBootEnabled on the SecurityProfile is true, 3) VTpmEnabled on the SecurityProfile is true.")]
[Parameter(
ParameterSetName = SimpleParameterSet,
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = "This flag disables the default behavior to install the Guest Attestation extension to the virtual machine if: 1) SecurityType is TrustedLaunch, 2) SecureBootEnabled on the SecurityProfile is true, 3) VTpmEnabled on the SecurityProfile is true.")]
public SwitchParameter DisableIntegrityMonitoring { get; set; }

[Parameter(
Expand Down Expand Up @@ -783,11 +788,11 @@ async Task StrategyExecuteCmdletAsync(IAsyncCmdlet asyncCmdlet)
// imagerefid is specifically shared gallery id, so don't want it.
else
{
this.SecurityType = ConstantValues.TrustedLaunchSecurityType;
if (!this.IsParameterBound(c => c.Image)
&& !this.IsParameterBound(c => c.ImageReferenceId)
&& !this.IsParameterBound(c => c.SharedGalleryImageId))
{
this.SecurityType = ConstantValues.TrustedLaunchSecurityType;
this.Image = ConstantValues.TrustedLaunchDefaultImageAlias;
if (!this.IsParameterBound(c => c.EnableSecureBoot))
{
Expand Down
6 changes: 3 additions & 3 deletions src/Compute/Compute/help/New-AzVM.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ New-AzVM [[-ResourceGroupName] <String>] [[-Location] <String>] [-EdgeZone <Stri
[-Priority <String>] [-EvictionPolicy <String>] [-MaxPrice <Double>] [-EncryptionAtHost]
[-HostGroupId <String>] [-SshKeyName <String>] [-GenerateSshKey] [-CapacityReservationGroupId <String>]
[-UserData <String>] [-ImageReferenceId <String>] [-PlatformFaultDomain <Int32>] [-HibernationEnabled]
[-vCPUCountAvailable <Int32>] [-vCPUCountPerCore <Int32>] [-DiskControllerType <String>]
[-vCPUCountAvailable <Int32>] [-vCPUCountPerCore <Int32>] [-DiskControllerType <String>] [-DisableIntegrityMonitoring]
[-SharedGalleryImageId <String>] [-SecurityType <String>] [-EnableVtpm <Boolean>]
[-EnableSecureBoot <Boolean>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
Expand Down Expand Up @@ -306,7 +306,7 @@ Set-AzVMSourceImage -VM $vmConfig -PublisherName $PublisherName -Offer $Offer -S
Add-AzVMNetworkInterface -VM $vmConfig -Id $nic.Id;
$vmConfig = Set-AzVMSecurityProfile -VM $vmConfig -SecurityType $securityType;
$vmConfig = Set-AzVMUefi -VM $vmConfig -EnableVtpm $vtpm -EnableSecureBoot $secureboot;
New-AzVM -ResourceGroupName $RGName -Location $loc -VM $vmConfig -DisableIntegrityMonitoring:$false;
New-AzVM -ResourceGroupName $RGName -Location $loc -VM $vmConfig;
# Verify values
$vm = Get-AzVM -ResourceGroupName $rgname -Name $vmName;
$vmExt = Get-AzVMExtension -ResourceGroupName $rgname -VMName $vmName -Name $extDefaultName;
Expand Down Expand Up @@ -548,7 +548,7 @@ This flag disables the default behavior to install the Guest Attestation extensi

```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: DefaultParameterSet
Parameter Sets: DefaultParameterSet, SimpleParameterSet
Aliases:

Required: False
Expand Down
3 changes: 3 additions & 0 deletions tools/StaticAnalysis/Exceptions/Az.Compute/ExampleIssues.csv
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@
"Az.Compute","Set-AzVMSecurityProfile","2","27","Capitalization_Conventions_Violated","5101","1","Set-AzVmUefi doesn't follow the Capitalization Conventions.","Set-AzVmUefi -VM $VirtualMachine -EnableVtpm $true -EnableSecureBoot $true","Check the Capitalization Conventions. Suggest format: Set-AzVMUefi"
"Az.Compute","Set-AzVMSecurityProfile","2","33","Capitalization_Conventions_Violated","5101","1","Get-AzVm doesn't follow the Capitalization Conventions.","Get-AzVm -ResourceGroupName $rgname -Name $vmname","Check the Capitalization Conventions. Suggest format: Get-AzVM"
"Az.Compute","New-AzVM","8","9","Invalid_Cmdlet","5000","1","New-AzResourceGroup is not a valid command name.","New-AzResourceGroup -Name $rgname -Location $loc -Force","Check the spell of New-AzResourceGroup."
"Az.Compute","New-AzVM","6","3","Invalid_Cmdlet","5000","1","New-AzResourceGroup is not a valid command name.","New-AzResourceGroup -Name $resourceGroupName -Location $loc -Force","Check the spell of New-AzResourceGroup."
"Az.Compute","New-AzVM","8","10","Invalid_Cmdlet","5000","1","New-AzResourceGroup is not a valid command name.","New-AzResourceGroup -Name $resourceGroupName -Location $loc -Force","Check the spell of New-AzResourceGroup."
"Az.Compute","New-AzVM","9","4","Invalid_Cmdlet","5000","1","New-AzResourceGroup is not a valid command name.","New-AzResourceGroup -Name $rgname -Location $loc -Force","Check the spell of New-AzResourceGroup."