Sha256: a07fcd2f2e3f1ce7953fa3c670106e74a4b656d57a3eacd1a059e3dd211a5301

Contents?: true

Size: 1.29 KB

Versions: 8

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

#
# Collect WAFv2 resources
#
class WAFV2 < Mapper
  #
  # Returns an array of resources.
  #
  # TODO: test live
  # TODO: resolve scope (e.g. CLOUDFRONT supported?)
  # TODO: confirm paging behavior
  #
  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'
          # struct.arn = "arn:aws:#{@service}:#{@region}::web_acl/#{acl.id}"

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

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

          # list_resources_for_web_acl
          @client.list_resources_for_web_acl({ web_acl_arn: 'ResourceArn' }).each do |response|
            struct.resources = response.resource_arns.map(&:to_h)
          end

          resources.push(struct.to_h)
        end
      end
    end

    resources
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
aws_recon-0.2.35 lib/aws_recon/collectors/wafv2.rb
aws_recon-0.2.34 lib/aws_recon/collectors/wafv2.rb
aws_recon-0.2.33 lib/aws_recon/collectors/wafv2.rb
aws_recon-0.2.32 lib/aws_recon/collectors/wafv2.rb
aws_recon-0.2.31 lib/aws_recon/collectors/wafv2.rb
aws_recon-0.2.30 lib/aws_recon/collectors/wafv2.rb
aws_recon-0.2.29 lib/aws_recon/collectors/wafv2.rb
aws_recon-0.2.28 lib/aws_recon/collectors/wafv2.rb