Class: Neetob::CLI::MonthlyAudit::InstancesAndAddons::Cloudflare::BotProtectionEnabled

Inherits:
Base
  • Object
show all
Defined in:
lib/neetob/cli/monthly_audit/instances_and_addons/cloudflare/bot_protection_enabled.rb

Constant Summary

Constants inherited from Base

Base::NEETO_APPS_LIST_LINK

Instance Attribute Summary

Attributes inherited from Base

#ui

Instance Method Summary collapse

Methods included from Utils

#camel_case_to_slug, #is_upper?, #symbolize_keys

Constructor Details

#initializeBotProtectionEnabled

Returns a new instance of BotProtectionEnabled.



10
11
12
# File 'lib/neetob/cli/monthly_audit/instances_and_addons/cloudflare/bot_protection_enabled.rb', line 10

def initialize
  super()
end

Instance Method Details

#runObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/neetob/cli/monthly_audit/instances_and_addons/cloudflare/bot_protection_enabled.rb', line 14

def run
  ui.success "### 3.2.6. Checking whether Bot Protection is enabled"

  domains_data = [["Domain", "Bot protection", "Audit Passed"]]
  ui.info("\n", print_to_audit_log: false)
  Neetob::CLI::Cloudflare::Base::ZONE_IDS.keys.select { |domain|
 domain.to_s.include?(".com") }.map do |domain|
    bot_fight_mode = Neetob::CLI::Cloudflare::BotFightMode.new(domain).run
    ui.info("Checking Bot fight mode for #{domain}", print_to_audit_log: false)
    audit_passed = bot_fight_mode == "on" ? "Yes" : "No"

    if audit_passed == "No"
      repo = domain_to_repo(domain.to_s)
      issue_url = GithubIssueCreation.new.create_issue(
        repo:, title: "Enable bot protection for #{domain}",
        description: "Bot Protection is not enabled for #{domain}.")
      audit_passed += " #{issue_url}"
    end
    domains_data << [domain, bot_fight_mode, audit_passed]
  end
  ui.print_table(domains_data)
end