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

CKV_AZURE_189 is not being marked as passed in Bicep code #6429

Open
mmassey1993 opened this issue Jun 10, 2024 · 3 comments
Open

CKV_AZURE_189 is not being marked as passed in Bicep code #6429

mmassey1993 opened this issue Jun 10, 2024 · 3 comments
Labels
checks Check additions or changes

Comments

@mmassey1993
Copy link

Describe the issue
The checkov scan is failing on CKV_AZURE_189 (Ensure public network access for key vault is disabled) even though the correct property is in place

Examples
resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' = {
name: keyVaultName
location: location
properties: {
sku: {
family: 'A'
name: 'standard'
}
tenantId: tenant().tenantId
enablePurgeProtection: true
enableSoftDelete: true
enabledForTemplateDeployment: true
enabledForDiskEncryption: true
enabledForDeployment: true
enableRbacAuthorization: true
publicNetworkAccess: 'Disabled'
}
}

I would expect this to work as public network access value is disabled

Additional context
I had an issue with a different checkov check, and the issue was because it was not checking for string values of "Enabled" or "Disabled" correctly in BICEP compared to terraform

@mmassey1993 mmassey1993 added the checks Check additions or changes label Jun 10, 2024
@mannycepeda1989
Copy link

mannycepeda1989 commented Jun 10, 2024

Hey @mmassey1993 when using changing the value from "publicNetworkAccess: 'Disabled' to lowercase 'disabled' seems to have fixed this issue for me.

Example of updated code:
resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' = {
name: keyVaultName
location: location
properties: {
sku: {
family: 'A'
name: 'standard'
}
tenantId: tenant().tenantId
enablePurgeProtection: true
enableSoftDelete: true
enabledForTemplateDeployment: true
enabledForDiskEncryption: true
enabledForDeployment: true
enableRbacAuthorization: true
publicNetworkAccess: 'disabled'
}
}

Seems to be the format that listed in the following documenatation:
https://learn.microsoft.com/en-us/azure/templates/microsoft.keyvault/vaults?pivots=deployment-language-bicep#resource-format:~:text=RegisteringDns%27%0A%27Succeeded%27-,publicNetworkAccess,the%20firewall%20rules%20are%20present%20we%20will%20not%20honor%20the%20rules.,-string

Other notes:
Checkov version 3.2.133

@mmassey1993
Copy link
Author

@mannycepeda1989 Thank you that has worked. However i use the same Disabled value for other things and it works perfectly fine. Would be nice if there was consistency or if it just use a lower() function to ensure its always the lowercase if that is what's needed.

@mmassey1993
Copy link
Author

The check also fails if the value is a parameter. Even if that parameters is "disabled" by default, it will still fail. Can checkov evaluate the parameter values?

@description('Optional. Whether or not public network access is allowed for this resource. For security reasons it should be disabled. If not specified, it will be disabled by default if private endpoints are set and networkAcls are not set.')
@Allowed([
'enabled'
'disabled'
])
param publicNetworkAccess string = 'disabled'

resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' = {
name: name
location: location
tags: tags
properties: {
enabledForDeployment: true
enabledForTemplateDeployment: true
enabledForDiskEncryption: true
enableSoftDelete: true
softDeleteRetentionInDays: softDeleteRetentionInDays
enableRbacAuthorization: true
enablePurgeProtection: true
tenantId: subscription().tenantId
accessPolicies: formattedAccessPolicies
sku: {
name: vaultSku
family: 'A'
}
networkAcls: {
defaultAction: 'Deny'
bypass: 'AzureServices'
}
publicNetworkAccess: publicNetworkAccess
}
}

@mmassey1993 mmassey1993 reopened this Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
checks Check additions or changes
Projects
None yet
Development

No branches or pull requests

2 participants