Class: S3Secure::PublicAccess::List

Inherits:
Base show all
Defined in:
lib/s3_secure/public_access/list.rb

Instance Method Summary collapse

Methods inherited from Base

#account_id

Methods inherited from CLI::Base

#buckets, #initialize

Methods included from CLI::Say

#say

Methods included from AwsServices

#sts

Methods included from AwsServices::S3

#check_bucket!, #new_s3_regional_client, #region, #region_map, #s3, #s3_client, #s3_regional_client

Constructor Details

This class inherits a constructor from S3Secure::CLI::Base

Instance Method Details

#runObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/s3_secure/public_access/list.rb', line 3

def run
  presenter = CliFormat::Presenter.new(@options)
  presenter.header = ["Bucket", "Block Public Access?"]

  buckets.each do |bucket|
    say "Getting bucket public access configuration for bucket #{bucket.color(:green)}"

    blocked = Show.new(bucket: bucket).blocked?
    row = [bucket, blocked]
    if @options[:blocked].nil?
      presenter.rows << row # always show policy
    elsif @options[:blocked]
      presenter.rows << row if blocked # only show if bucket is blocked
    else
      presenter.rows << row unless blocked # only show if bucket is unblocked
    end
  end

  presenter.show
end