Linter szabály – az adminPasswordnek biztonságos értéket kell hozzárendelnie.
Ez a szabály megkeresi a tulajdonság elérési útjának properties.osProfile.adminPassword
értékét olyan típusú Microsoft.Compute/virtualMachines
erőforrások esetében, amelyek Microsoft.Compute/virtualMachineScaleSets
nem rendelkeznek biztonságos értékkel.
Linter-szabály kódja
A bicep-konfigurációs fájlban a következő érték használatával szabhatja testre a szabálybeállításokat:
use-secure-value-for-secure-inputs
Megoldás
Rendeljen hozzá egy biztonságos értéket a tulajdonsághoz a típus vagy a típus Microsoft.Compute/virtualMachines
Microsoft.Compute/virtualMachineScaleSets
típusú erőforrások tulajdonságútvonalávalproperties.osProfile.adminPassword
. Ne használjon literális értéket. Ehelyett hozzon létre egy paramétert a @secure()
jelszó dekoratőrével , és rendelje hozzá adminPassword
.
Az alábbi példák sikertelenek a teszt során, mert az adminPassword
nem biztonságos érték.
resource ubuntuVM 'Microsoft.Compute/virtualMachineScaleSets@2023-09-01' = {
name: 'name'
location: 'West US'
properties: {
virtualMachineProfile: {
osProfile: {
adminUsername: 'adminUsername'
adminPassword: 'adminPassword'
}
}
}
}
resource ubuntuVM 'Microsoft.Compute/virtualMachines@2023-09-01' = {
name: 'name'
location: 'West US'
properties: {
osProfile: {
computerName: 'computerName'
adminUsername: 'adminUsername'
adminPassword: 'adminPassword'
}
}
}
param adminPassword string
resource ubuntuVM 'Microsoft.Compute/virtualMachines@2023-09-01' = {
name: 'name'
location: 'West US'
properties: {
osProfile: {
computerName: 'computerName'
adminUsername: 'adminUsername'
adminPassword: adminPassword
}
}
}
Az alábbi példa megfelel a tesztnek.
@secure()
param adminPassword string
@secure()
param adminUsername string
param location string = resourceGroup().location
resource ubuntuVM 'Microsoft.Compute/virtualMachines@2023-09-01' = {
name: 'name'
location: location
properties: {
osProfile: {
computerName: 'computerName'
adminUsername: adminUsername
adminPassword: adminPassword
}
}
}
Következő lépések
A linterről további információt a Bicep-linter használata című témakörben talál.