[Bug]: Key Vault: "Ensure 'Purge protection' is set to 'Enabled'" never fails because the rule queries properties.enablePurgeProtection

Abierto Apto para principiantes
#199 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
78/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
azure, powershell
Área
cloud, security

Línea de trabajo

Abre rules/findings/azure/keyvault/azure-keyvault-purge-protection-not-enabled.json y compara su condición con la regla de Key Vault recuperable. Comprueba cómo New-MonkeyVaultObject.ps1 normaliza el valor que falta y, después, ejecuta la regla contra un vault sin protección contra el borrado. La tarea estará terminada cuando ese vault no supere la regla de protección contra el borrado, en lugar de superarla.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug status/needs-triage

What happened?
Every Key Vault without purge protection is reported as pass for azure_key_vault_purge_protection_disabled (rules/findings/azure/keyvault/azure-keyvault-purge-protection-not-enabled.json).

The rule condition is:

["properties.enablePurgeProtection", "eq", "false"]

properties holds the raw ARM properties of the vault. ARM only accepts true for enablePurgeProtection (Key Vault reference: "Enabling this functionality is irreversible - that is, the property does not accept false as its value"). A vault that never had purge protection enabled has no enablePurgeProtection value at all, and $null -eq $false is false, so the condition never matches.

New-MonkeyVaultObject.ps1 already normalises the value (line 75):

protection = [PSCustomObject]@{
    enablePurgeProtection = If($null -ne $InputObject.Properties.PsObject.Properties.Item('enablePurgeProtection')){$InputObject.Properties.enablePurgeProtection}Else{$false};

How to reproduce it

  1. Use a Key Vault created without purge protection. az keyvault show -n <vault> --query "{purge:properties.enablePurgeProtection, softDelete:properties.enableSoftDelete}" returns "purge": null, "softDelete": true.
  2. Run Invoke-Monkey365 -Instance Azure with the default ruleset.
  3. azure_key_vault_purge_protection_disabled is reported as pass.

Expected behavior
The rule fails for vaults without purge protection.

Suggested fix
Query the normalised value, as the "recoverable" rule already does:

["protection.enablePurgeProtection", "eq", "false"]

From where are you running Monkey365?

  • Resource: Docker container
  • OS: Linux (Ubuntu 24.04)
  • PowerShell Version: 7.6.9
  • Monkey365 Version: 1.0.5 (also 1.0.0, PowerShell Gallery)
  • Others: app-only authentication with access tokens

Additional context
Same pattern as the Key Vault RBAC issue (value read or queried at the wrong level), reported separately.

Lenguaje dominante
PowerShell
Estrellas
1.4k
Forks
144
Merge medio
1 d 21 h
PR fusionados (30 d)
1

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de silverhack/monkey365

Todos los issues de silverhack/monkey365

Issues similares

Más issues de Cloud

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.