Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from azure.mgmt.resource.policy import PolicyClient | ||
|
||
from ScoutSuite.core.console import print_exception | ||
from ScoutSuite.providers.utils import run_concurrently | ||
|
||
|
||
class PolicyFacade: | ||
def __init__(self, credentials, subscription_id): | ||
self._client = PolicyClient(credentials, subscription_id, '') | ||
|
||
async def get_policies_assignments(self): | ||
try: | ||
return await run_concurrently(lambda: list(self._client.policy_assignments.list())) | ||
except Exception as e: | ||
print_exception('Failed to retrieve users: {}'.format(e)) | ||
return [] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from ScoutSuite.providers.azure.resources.base import AzureCompositeResources | ||
|
||
from .policy_assignments import PolicyAssignments | ||
|
||
class Policies(AzureCompositeResources): | ||
_children = [ | ||
(PolicyAssignments, 'policy_assignments'), | ||
] | ||
|
||
async def fetch_all(self): | ||
await self._fetch_children(resource_parent=self) |
14 changes: 14 additions & 0 deletions
14
ScoutSuite/providers/azure/resources/policy/policy_assignments.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from ScoutSuite.providers.azure.resources.base import AzureResources | ||
|
||
|
||
class PolicyAssignments(AzureResources): | ||
async def fetch_all(self): | ||
for raw_policy in await self.facade.policies.get_policies_assignments(): | ||
id, policy = self._parse_policy(raw_policy) | ||
self[id] = policy | ||
|
||
def _parse_policy(self, raw_policy): | ||
policy = {} | ||
policy['id'] = raw_policy.id | ||
|
||
return policy['id'], policy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters