Class: WAFV2

Inherits:
Mapper show all
Defined in:
lib/aws_recon/collectors/wafv2.rb

Overview

Collect WAFv2 resources

Constant Summary

Constants inherited from Mapper

Mapper::SINGLE_REGION_SERVICES

Instance Method Summary collapse

Methods inherited from Mapper

#initialize

Constructor Details

This class inherits a constructor from Mapper

Instance Method Details

#collectObject

Returns an array of resources.

TODO: resolve scope (e.g. CLOUDFRONT supported?)



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/aws_recon/collectors/wafv2.rb', line 12

def collect
  resources = []

  #
  # list_web_acls
  #
  # %w[CLOUDFRONT REGIONAL].each do |scope|
  %w[REGIONAL].each do |scope|
    @client.list_web_acls({ scope: scope }).each_with_index do |response, page|
      log(response.context.operation_name, page)

      response.web_acls.each do |acl|
        struct = OpenStruct.new(acl.to_h)
        struct.type = 'web_acl'

        params = {
          name: acl.name,
          scope: scope,
          id: acl.id
        }

        # get_web_acl
        @client.get_web_acl(params).each do |r|
          struct.arn = r.web_acl.arn
          struct.details = r.web_acl
        end

        # list_resources_for_web_acl
        @client.list_resources_for_web_acl({ web_acl_arn: acl.arn }).each do |r|
          struct.resources = r.resource_arns.map(&:to_h)
        end

        resources.push(struct.to_h)
      end
    end
  end

  resources
end