in Deployment/RateRuleReload.py [0:0]
def get_webacl(log, scope_type, policy, assumed_session):
# Setting up variables
webacl_client = ''
webacl_list = ''
webacl_client = assumed_session.client('wafv2')
webacl_list = webacl_client.list_web_acls(
Scope=scope_type,
Limit=100
)
# Append all webacls if it is more than 100
loop_pointer = True
nextmarker = webacl_list['NextMarker']
while loop_pointer:
temp_list = webacl_client.list_web_acls(
Scope=scope_type,
NextMarker=nextmarker,
Limit=100
)
#print(temp_list)
if temp_list['WebACLs']:
webacl_list.append(temp_list)
nextmarker = temp_list['NextMarker']
if not temp_list['WebACLs']:
#print('Breaking while loop')
loop_pointer = ''
#print(webacl_list)
for policylist in range(len(policy)):
policy_name = policy[policylist]['Name']
policy_rbpostvalue = policy[policylist]['RateBasedPostValue']
policy_rbgetvalue = policy[policylist]['RateBasedGetValue']
fmspolicy_name = 'FMManagedWebACLV2' + str(policy_name)
#print(fmspolicy_name)
for webaclindex in range(len(webacl_list['WebACLs'])):
wafArn = webacl_list['WebACLs'][webaclindex]['ARN']
arn_split = (wafArn.split(':'))
req = (arn_split[5])
arn_split_2 = (req.split('/'))
scope_lower = (arn_split_2[0])
webacl_scope = scope_lower.upper()
webacl_name = (arn_split_2[2])
webacl_id = (arn_split_2[3])
if wafArn.find('arn:aws:wafv2:') >= 0:
if webacl_name.find(fmspolicy_name) >= 0:
log.info('[RateBasedRule-Reload] Applying RateBasedRule for %s' %webacl_name)
update_raterule(log, assumed_session, webacl_scope, webacl_name, webacl_id, policy_rbpostvalue, policy_rbgetvalue)