Skip to content

Commit

Permalink
extraction examples
Browse files Browse the repository at this point in the history
  • Loading branch information
omriyoffe-panw committed Oct 27, 2024
1 parent dcce425 commit 9d05271
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion checkov/arm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,22 @@ def get_files_definitions(


def extract_resource_name_from_resource_id_func(resource_id: str) -> str:
# Extract name from resourceId function
'''
Examples:
resourceId('Microsoft.Network/virtualNetworks/', virtualNetworkName) -> virtualNetworkName
'''
return clean_string(resource_id.split(',')[-1].split(')')[0])


def extract_resource_name_from_reference_func(reference: str) -> str:
'''
Examples:
reference('storageAccountName') -> storageAccountName
reference('myStorage').primaryEndpoints -> myStorage
reference('myStorage', '2022-09-01', 'Full').location -> myStorage
reference(resourceId('storageResourceGroup', 'Microsoft.Storage/storageAccounts', 'storageAccountName')), '2022-09-01') -> storageAccountName
reference(resourceId('Microsoft.Network/publicIPAddresses', 'ipAddressName')) -> ipAddressName
'''
resource_name = ''.join(reference.split('reference(', 1)[1].split(')')[:-1])
if 'resourceId' in resource_name:
return clean_string(
Expand Down

0 comments on commit 9d05271

Please sign in to comment.