Sha256: 1593a9236d93d279c9b5abb1d1947d91bae08656f469d810018be573d0bd8c6a

Contents?: true

Size: 1.12 KB

Versions: 27

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

#
# Collect WAFv2 resources
#
class WAFV2 < Mapper
  #
  # Returns an array of resources.
  #
  # TODO: resolve scope (e.g. CLOUDFRONT supported?)
  #
  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
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
aws_recon-0.5.33 lib/aws_recon/collectors/wafv2.rb
aws_recon-0.5.32 lib/aws_recon/collectors/wafv2.rb
aws_recon-0.5.31 lib/aws_recon/collectors/wafv2.rb
aws_recon-0.5.30 lib/aws_recon/collectors/wafv2.rb
aws_recon-0.5.29 lib/aws_recon/collectors/wafv2.rb
aws_recon-0.5.28 lib/aws_recon/collectors/wafv2.rb
aws_recon-0.5.27 lib/aws_recon/collectors/wafv2.rb
aws_recon-0.5.26 lib/aws_recon/collectors/wafv2.rb
aws_recon-0.5.25 lib/aws_recon/collectors/wafv2.rb
aws_recon-0.5.24 lib/aws_recon/collectors/wafv2.rb
aws_recon-0.5.23 lib/aws_recon/collectors/wafv2.rb
aws_recon-0.5.22 lib/aws_recon/collectors/wafv2.rb
aws_recon-0.5.21 lib/aws_recon/collectors/wafv2.rb
aws_recon-0.5.20 lib/aws_recon/collectors/wafv2.rb
aws_recon-0.5.19 lib/aws_recon/collectors/wafv2.rb
aws_recon-0.5.18 lib/aws_recon/collectors/wafv2.rb
aws_recon-0.5.17 lib/aws_recon/collectors/wafv2.rb
aws_recon-0.5.16 lib/aws_recon/collectors/wafv2.rb
aws_recon-0.5.15 lib/aws_recon/collectors/wafv2.rb
aws_recon-0.5.14 lib/aws_recon/collectors/wafv2.rb