Linter szabály – használja a védett Gépház parancsOtToExecute titkos kulcsok
Ez a szabály egy egyéni szkripterőforrás beállítástulajdonságában megkeresi a titkos kódok lehetséges expozícióját.
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:
protect-commandtoexecute-secrets
Megoldás
Egyéni szkripterőforrások esetén az értéket a commandToExecute
tulajdonságobjektum helyett a protectedSettings
settings
tulajdonságobjektum alá kell helyezni, ha titkos adatokat, például jelszót tartalmaz. A titkos adatok például biztonságos paraméterekben, függvényekben, list*
például listKeysben vagy egyéni szkriptek argumentumaiban találhatók.
Ne használjon titkos adatokat az settings
objektumban, mert tiszta szöveget használ. További információ: Microsoft.Compute virtualMachines/extensions, Custom Script Extension for Windows, use the Azure Custom Script Extension Version 2 with Linux virtual machines.
Az alábbi példa meghiúsul, mert commandToExecute
a megadott érték alatt van megadva settings
, és egy biztonságos paramétert használ.
param vmName string
param location string
param fileUris string
param storageAccountName string
resource storageAccount 'Microsoft.Storage/storageAccounts@2022-09-01' existing = {
name: storageAccountName
}
resource customScriptExtension 'Microsoft.HybridCompute/machines/extensions@2023-03-15-preview' = {
name: '${vmName}/CustomScriptExtension'
location: location
properties: {
publisher: 'Microsoft.Compute'
type: 'CustomScriptExtension'
autoUpgradeMinorVersion: true
settings: {
fileUris: split(fileUris, ' ')
commandToExecute: 'mycommand ${storageAccount.listKeys().keys[0].value}'
}
}
}
A javításhoz helyezze át a commandToExecute tulajdonságot az protectedSettings
objektumra.
param vmName string
param location string
param fileUris string
param storageAccountName string
resource storageAccount 'Microsoft.Storage/storageAccounts@2022-09-01' existing = {
name: storageAccountName
}
resource customScriptExtension 'Microsoft.HybridCompute/machines/extensions@2023-03-15-preview' = {
name: '${vmName}/CustomScriptExtension'
location: location
properties: {
publisher: 'Microsoft.Compute'
type: 'CustomScriptExtension'
autoUpgradeMinorVersion: true
settings: {
fileUris: split(fileUris, ' ')
}
protectedSettings: {
commandToExecute: 'mycommand ${storageAccount.listKeys().keys[0].value}'
}
}
}
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.