Module: Awspec::Helper::Finder::Wafv2

Included in:
Awspec::Helper::Finder
Defined in:
lib/awspec/helper/finder/wafv2.rb

Instance Method Summary collapse

Instance Method Details

#find_ip_set(scope, name) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/awspec/helper/finder/wafv2.rb', line 6

def find_ip_set(scope, name)
  ip_sets = select_all_ip_sets(scope)
  ip_set  = ip_sets.find do |i|
    i.name == name
  end
  return false unless ip_set

  get_ip_set(scope, name, ip_set.id)
end

#find_web_acl(scope, name) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/awspec/helper/finder/wafv2.rb', line 26

def find_web_acl(scope, name)
  web_acls = select_all_web_acls(scope)
  web_acl = web_acls.find do |acl|
    acl.name == name
  end
  return false unless web_acl

  get_web_acl(scope, name, web_acl.id)
end

#get_ip_set(scope, name, id) ⇒ Object



21
22
23
24
# File 'lib/awspec/helper/finder/wafv2.rb', line 21

def get_ip_set(scope, name, id)
  res = wafv2_client.get_ip_set({ name: name, scope: scope, id: id })
  res.ip_set
end

#get_web_acl(scope, name, id) ⇒ Object



41
42
43
44
# File 'lib/awspec/helper/finder/wafv2.rb', line 41

def get_web_acl(scope, name, id)
  res = wafv2_client.get_web_acl({ name: name, scope: scope, id: id })
  res.web_acl
end

#select_all_ip_sets(scope) ⇒ Object



16
17
18
19
# File 'lib/awspec/helper/finder/wafv2.rb', line 16

def select_all_ip_sets(scope)
  res = wafv2_client.list_ip_sets({ scope: scope })
  res.ip_sets
end

#select_all_web_acls(scope) ⇒ Object



36
37
38
39
# File 'lib/awspec/helper/finder/wafv2.rb', line 36

def select_all_web_acls(scope)
  res = wafv2_client.list_web_acls({ scope: scope })
  res.web_acls
end