-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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(azure containerregistry): gather service infos and checks disabled admin user #5191
feat(azure containerregistry): gather service infos and checks disabled admin user #5191
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.
Thaks for the contribution, it is a great job 💯 , please review my comments
prowler/providers/azure/services/containerregistry/containerregistry_service.py
Show resolved
Hide resolved
super().__init__(ContainerRegistryManagementClient, provider) | ||
self.registries = self._get_container_registries(provider) | ||
|
||
def _get_container_registries(self, provider): |
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.
def _get_container_registries(self, provider): | |
def _get_container_registries(self): |
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.
see above.
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.
It is mandatory in the father constructor, in the methods that you define is not mandatory because you are not using in any line of the method. The above case was a fail, I only wanted to change this one.
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.
Ok understood. Is fixed.
) | ||
|
||
|
||
class Test_ContainerRegistry_Service: |
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.
class Test_ContainerRegistry_Service: | |
class TestContainerRegistryService: |
|
||
|
||
class Test_ContainerRegistry_Service: | ||
def test_container_registry(self): |
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.
def test_container_registry(self): | |
def test_get_container_registry(self): |
) | ||
|
||
|
||
class TestContainerRegistryAdminUserDisabled: |
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.
class TestContainerRegistryAdminUserDisabled: | |
class Test_containerregistry_admin_user_disabled: |
...ry/containerregistry_admin_user_disabled/containerregistry_admin_user_disabled.metadata.json
Outdated
Show resolved
Hide resolved
...ry/containerregistry_admin_user_disabled/containerregistry_admin_user_disabled.metadata.json
Outdated
Show resolved
Hide resolved
"CLI": "az acr update --name <RegistryName> --resource-group <ResourceGroupName> --admin-user-enabled false", | ||
"NativeIaC": "", | ||
"Other": "", | ||
"Terraform": "resource \"azurerm_container_registry\" \"example\" { admin_enabled = false }" |
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.
"Terraform": "resource \"azurerm_container_registry\" \"example\" { admin_enabled = false }" | |
"Terraform": "" |
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.
Why delete the example?
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.
For now we are not hardcoding Terraform in this field, it is commonly used to add a link with the Terraform code. I think it could be weird and in a future could be changed but now I think it is better to leave it empty.
...ry/containerregistry_admin_user_disabled/containerregistry_admin_user_disabled.metadata.json
Outdated
Show resolved
Hide resolved
"RelatedUrl": "https://docs.microsoft.com/en-us/azure/container-registry/administrative-user", | ||
"Remediation": { | ||
"Code": { | ||
"CLI": "az acr update --name <RegistryName> --resource-group <ResourceGroupName> --admin-user-enabled false", |
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.
I think the parameter is --admin-user-enabled
, see here.
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.
Here indicates that the flag is --admin-enabled
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.
Ok, you are right. Fixed.
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.
Thaks for the contribution, it is a great job 💯 , please review my comments
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5191 +/- ##
==========================================
- Coverage 89.08% 89.08% -0.01%
==========================================
Files 989 992 +3
Lines 30407 30474 +67
==========================================
+ Hits 27089 27148 +59
- Misses 3318 3326 +8 ☔ View full report in Codecov by Sentry. |
Co-authored-by: Rubén De la Torre Vico <[email protected]>
Co-authored-by: Rubén De la Torre Vico <[email protected]>
Co-authored-by: Rubén De la Torre Vico <[email protected]>
Co-authored-by: Rubén De la Torre Vico <[email protected]>
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.
Pleases check my comments.
"RelatedUrl": "https://docs.microsoft.com/en-us/azure/container-registry/administrative-user", | ||
"Remediation": { | ||
"Code": { | ||
"CLI": "az acr update --name <RegistryName> --resource-group <ResourceGroupName> --admin-user-enabled false", |
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.
I think the parameter is --admin-user-enabled
, see here.
"CLI": "az acr update --name <RegistryName> --resource-group <ResourceGroupName> --admin-user-enabled false", | ||
"NativeIaC": "", | ||
"Other": "", | ||
"Terraform": "resource \"azurerm_container_registry\" \"example\" { admin_enabled = false }" |
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.
Why delete the example?
registries = {} | ||
for subscription, client in self.clients.items(): | ||
try: | ||
registries.update({subscription: []}) |
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.
You mean like this?
for subscription, client in self.clients.items():
try:
+ registries.update({subscription: {}})
registries_list = client.registries.list()
for registry in registries_list:
resource_group = self._get_resource_group(registry.id)
+ registries[registry.id].append(
ContainerRegistryInfo(
id=getattr(registry, "id", ""),
name=getattr(registry, "name", ""),
location=getattr(registry, "location", ""),
resource_group=resource_group,
sku=getattr(registry.sku, "name", ""),
login_server=getattr(registry, "login_server", ""),
public_network_access=getattr(
registry, "public_network_access", ""
),
admin_user_enabled=getattr(
registry, "admin_user_enabled", ""
),
monitor_diagnostic_settings=self._get_registry_monitor_settings(
registry.name, resource_group, subscription
),
)
)
…-user' of https://github.com/johannes-engler-mw/prowler into feat/azure-containerregistry-service-and-disabled-admin-user
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.
Looks great, thanks for the contribution 🔝 🚀
@@ -9,18 +9,18 @@ def execute(self) -> list[Check_Report_Azure]: | |||
findings = [] | |||
|
|||
for subscription, registries in containerregistry_client.registries.items(): | |||
for registry_id, ContainerRegistryInfo in registries.items(): | |||
for registry_id, conatiner_registry_info in registries.items(): |
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.
Misspelling of container, please adapt @puchy22
{ | ||
"Provider": "azure", | ||
"CheckID": "containerregistry_admin_user_disabled", | ||
"CheckTitle": "Admin User is disabled for Azure Container Registry", |
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.
"CheckTitle": "Admin User is disabled for Azure Container Registry", | |
"CheckTitle": "Ensure admin User is disabled for Azure Container Registry", |
"ResourceIdTemplate": "", | ||
"Severity": "high", | ||
"ResourceType": "ContainerRegistry", | ||
"Description": "Enabling the admin user for Azure Container Registry (ACR) can pose security risks as it grants unrestricted access to the registry. It is recommended to disable the admin user and utilize Role-Based Access Control (RBAC) instead.", |
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.
"Description": "Enabling the admin user for Azure Container Registry (ACR) can pose security risks as it grants unrestricted access to the registry. It is recommended to disable the admin user and utilize Role-Based Access Control (RBAC) instead.", | |
"Description": "Ensure that the admin user is disabled and Role-Based Access Control (RBAC) is used instead since it could grant unrestricted access to the registry", |
findings = [] | ||
|
||
for subscription, registries in containerregistry_client.registries.items(): | ||
for registry_id, conatiner_registry_info in registries.items(): |
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.
for registry_id, conatiner_registry_info in registries.items(): | |
for registry_id, container_registry_info in registries.items(): |
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.
Thanks for your contribution @johannes-engler-mw !
Context
This PR adds support to checking Azure Container Registries for security relevant problems.
Description
This PR adds the following features:
Checklist
License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.