-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat(terraform): add CKV_AZURE_248 - Azure batch account network access restriction #6928
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice! 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! A few notes:
- I believe you need to adjust the checks for the default value of one of the fields (the other is accurately good when missing).
- In the description, can you mention that this is aligned to the run policy ID
ea27ffec-c8ba-4dbb-95e4-159b5350c94f
for when we platformize it? - Make sure to add the
evaluated_keys
as @bo156 mentioned.
public_network_access = conf.get('public_network_access_enabled', [None])[0] | ||
if not public_network_access: | ||
return CheckResult.PASSED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default for public_network_access_enabled is true
which is bad. If this field is missing you need to check the default_action before passing/failing.
Looks like you'll need to adjust the ARM one as well for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct, updated the logic accordingly
FORBIDDEN_NETWORK_ACCESS_DEFAULT_ACTION = "allow" | ||
|
||
def __init__(self) -> None: | ||
name = "Ensure that Azure Batch account public network access is 'enabled' account access default action is 'ignore'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name = "Ensure that Azure Batch account public network access is 'enabled' account access default action is 'ignore'" | |
name = "Ensure that Azure Batch account public network access is disabled and account access default action is deny" |
class AzureBatchAccountEndpointAccessDefaultAction(BaseResourceCheck): | ||
|
||
def __init__(self) -> None: | ||
name = "Ensure that Azure Batch account public network access is 'enabled' account access default action is 'ignore'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name = "Ensure that Azure Batch account public network access is 'enabled' account access default action is 'ignore'" | |
name = "Ensure that Azure Batch account public network access is disabled and account access default action is deny" |
default_action = "allow" | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | |
} | |
resource "azurerm_batch_account" "fail_bad_default_action_no_public_network" { | |
name = "testbatchaccount" | |
resource_group_name = "group" | |
location = "azurerm_resource_group.example.location" | |
pool_allocation_mode = "BatchService" | |
network_profile { | |
account_access { | |
default_action = "allow" | |
} | |
} | |
} |
I suggest adding this scenario and adding it to the test cases for both Terraform and ARM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added + in arm test
…mon checks assertions function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job!
…ss restriction (#6928) * add azure batch account network access validation - arm * add azure batch account network access validation - terraform
…ss restriction (#6928) * add azure batch account network access validation - arm * add azure batch account network access validation - terraform
User description
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
New/Edited policies (Delete if not relevant)
Description
CKV_AZURE_248 to arm, tf - when
publicNetworkAccess
is enabled, check for thenetworkProfile. accountAccess.defaultAction
attribute, fail if "allow".This check aligns to the run policy ID
ea27ffec-c8ba-4dbb-95e4-159b5350c94f
Fix
either disable
publicNetworkAccess
or movenetworkProfile. accountAccess.defaultAction
to "deny"Checklist:
Generated description
Below is a concise technical summary of the changes proposed in this PR:
Implements a new security check (CKV_AZURE_248) for Azure Batch accounts in both ARM and Terraform. The check ensures that when public network access is enabled, the account access default action is set to 'deny'. Adds implementation files for both ARM and Terraform, along with corresponding test files and examples. Updates the common test assertion utility to support more detailed validations.
Modified files (1)
Latest Contributors(0)
Modified files (2)
Latest Contributors(0)
Modified files (5)
Latest Contributors(0)