Sha256: 66b28898a719bbbd4d70a2010b7c7d252abe4df8e9e477c3736dff7cb4404238

Contents?: true

Size: 1.49 KB

Versions: 10

Compression:

Stored size: 1.49 KB

Contents

module Outliers
  module Resources
    module Aws
      module S3
        class Bucket < Resource

          def empty?
            logger.debug "Bucket #{id} has #{count} objects."

            count == 0
          end

          def no_public_objects?
            passed = true
            
            logger.info "Validating #{objects.count} objects in '#{id}' are private."

            objects.each do |o|
              logger.debug "Verifying '#{o.key}' is private."
              o.acl.grants.select do |g|
                grantee = Nokogiri::XML(g.grantee.to_s).children.children.children.to_s
                if grantee == "http://acs.amazonaws.com/groups/global/AllUsers" || grantee == "http://acs.amazonaws.com/groups/global/AuthenticatedUsers"
                  logger.debug "Object '#{o.key}' in '#{id}' has public grant '#{grantee}'."
                  passed = false
                end
              end
            end

            logger.debug "Verification of '#{id}' #{passed ? 'passed' : 'failed'}."

            passed
          end

          def not_configured_as_website?
            !configured_as_website?
          end

          def configured_as_website?
            !website_configuration.nil?
          end

          private

          def website_configuration
            source.website_configuration
          end

          def count
            objects.count
          end

          def objects
            @objects ||= source.objects
          end

        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
outliers-0.6.0 lib/outliers/resources/aws/s3/bucket.rb
outliers-0.5.1 lib/outliers/resources/aws/s3/bucket.rb
outliers-0.5.0 lib/outliers/resources/aws/s3/bucket.rb
outliers-0.5.0.beta3 lib/outliers/resources/aws/s3/bucket.rb
outliers-0.5.0.beta2 lib/outliers/resources/aws/s3/bucket.rb
outliers-0.5.0.beta1 lib/outliers/resources/aws/s3/bucket.rb
outliers-0.3.3 lib/outliers/resources/aws/s3/bucket.rb
outliers-0.3.2 lib/outliers/resources/aws/s3/bucket.rb
outliers-0.3.1 lib/outliers/resources/aws/s3/bucket.rb
outliers-0.3.0 lib/outliers/resources/aws/s3/bucket.rb