Class: Outliers::Resources::Aws::S3::Bucket

Inherits:
Outliers::Resource show all
Defined in:
lib/outliers/resources/aws/s3/bucket.rb

Instance Attribute Summary

Attributes inherited from Outliers::Resource

#source

Instance Method Summary collapse

Methods inherited from Outliers::Resource

#id, #initialize, key, #method_missing, verifications

Constructor Details

This class inherits a constructor from Outliers::Resource

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Outliers::Resource

Instance Method Details

#configured_as_website?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/outliers/resources/aws/s3/bucket.rb', line 38

def configured_as_website?
  !website_configuration.nil?
end

#empty?Boolean

Returns:

  • (Boolean)


7
8
9
10
11
# File 'lib/outliers/resources/aws/s3/bucket.rb', line 7

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

  count == 0
end

#no_public_objects?Boolean

Returns:

  • (Boolean)


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/outliers/resources/aws/s3/bucket.rb', line 13

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

#not_configured_as_website?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/outliers/resources/aws/s3/bucket.rb', line 34

def not_configured_as_website?
  !configured_as_website?
end