neetob 0.5.29 → 0.5.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60a560c06d296ab7f0c5654305fe6925319b7165cf0748645537c7f548676ec9
4
- data.tar.gz: 4934ce04f1a4dcd547e5b4887095d549fd798c5c4447b0106760938f5d4bf413
3
+ metadata.gz: b1ba5707c65bd2809d097f8bdb271cb6806faa0d99268c15f30791d041859210
4
+ data.tar.gz: 78ea06fa08c637a614c6f50707a3d6b0d1abf1e245a23fa3d73705341741ba3e
5
5
  SHA512:
6
- metadata.gz: f5ef8c07638328dc5115efac10a03d09fb331e9137566eca0b553975c4d82835fffa6874f6d46cac9db67334e8a741187d7f099898adbb98f7e4121f0cffc97c
7
- data.tar.gz: 35f7b37bd40f1064f874ab1afa3977449fc3ecd7a79ddda9a7b7250573249c57dc492e907ab908a6e7fe85ec4ef96bf36542c8b7c80e791c42feda4e0523623b
6
+ metadata.gz: abfe56f066722258be83bff6e71c1298d596203b5e30cf40a4b583a56d5c39294facebc6df13f18adace740d46069b81382f4481d59359c26fd85d759eff0fab
7
+ data.tar.gz: 04ce3f56cef72e25587fe957cd71d5a5361bfc9be3c89f363c4775e96c99f3288e2882c8ec73c3c762fb2a42bd96e2f8c84e206dd0416ae58eb662f73f9dcf73
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- neetob (0.5.29)
4
+ neetob (0.5.30)
5
5
  brakeman (~> 5.0)
6
6
  chronic
7
7
  dotenv (~> 2.8.1)
@@ -17,47 +17,22 @@ module Neetob
17
17
  end
18
18
 
19
19
  def run
20
- raise(StandardError, "HEROKU_API_KEY is not given") if ENV["HEROKU_API_KEY"].nil?
20
+ addons_list_heroku_output = `heroku addons -a #{app}`
21
21
 
22
- url = create_url(app)
23
- response = get(url)
24
- if response.any? { |addon| addon[:addon_service][:name] == "judoscale" }
25
- ui.success("Judoscale addon is #{print_success('enabled')} for #{app}")
26
- else
27
- ui.error("Judoscale #{print_failure('not present')} for #{app}")
28
- end
29
- end
22
+ judoscale_addon = addons_list_heroku_output.lines.select { |line| line.include?("judoscale") }.first
30
23
 
31
- private
32
-
33
- def create_url(app)
34
- "https://api.heroku.com/apps/#{app}/addons"
35
- end
24
+ judoscale_addon_enabled = judoscale_addon && judoscale_addon.include?("created")
36
25
 
37
- def parse_response(http_result)
38
- case http_result
39
- when Net::HTTPSuccess
40
- compressed_string = StringIO.new(http_result.body)
41
- response = Zlib::GzipReader.new(compressed_string).read
42
- JSON.parse(response, symbolize_names: true)
43
- else
44
- error_message = JSON.parse(http_result.body)["message"]
45
- raise(StandardError, "Request failed with status code #{http_result.code}: #{error_message}")
46
- end
26
+ if judoscale_addon_enabled
27
+ ui.success("Judoscale addon is enabled for #{app}.", print_to_audit_log: false)
28
+ else
29
+ ui.error("Judoscale addon is not enabled for #{app}.", print_to_audit_log: false)
47
30
  end
48
31
 
49
- def get(url,
50
- headers: { "Accept" => "application/vnd.heroku+json; version=3", "Authorization" => "Bearer #{ENV["HEROKU_API_KEY"]}" })
51
- uri = URI(url)
52
- request = Net::HTTP::Get.new(uri)
53
- headers.each { |key, value| request[key] = value }
54
-
55
- response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
56
- http.request(request)
57
- end
58
-
59
- parse_response(response)
32
+ if Thread.current[:audit_mode]
33
+ { judoscale_addon_enabled: }
60
34
  end
35
+ end
61
36
  end
62
37
  end
63
38
  end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../base"
4
+
5
+ module Neetob
6
+ class CLI
7
+ module Heroku
8
+ class Certs < Base
9
+ attr_accessor :app
10
+
11
+ def initialize(app)
12
+ super()
13
+ @app = app
14
+ end
15
+
16
+ def run
17
+ certificates_list_heroku_output = `heroku certs -a #{app}`
18
+ ui.success("Certificates of #{app}", print_to_audit_log: false)
19
+ ui.info(certificates_list_heroku_output, print_to_audit_log: false)
20
+
21
+ if Thread.current[:audit_mode]
22
+ certificates_list_heroku_output.lines[2..].map do |line|
23
+ match = line.match(
24
+ /^\s*(\S+)\s+([^\d]+?)(?=\s+(\d{4}-\d{2}-\d{2} \d{2}:\d{2} UTC))/
25
+ )
26
+ next unless match
27
+
28
+ {
29
+ name: match[1],
30
+ common_names: match[2],
31
+ expires: match[3]
32
+ }
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -7,6 +7,7 @@ require_relative "execute"
7
7
  require_relative "stack"
8
8
  require_relative "autoscaling_config"
9
9
  require_relative "maintenance_window"
10
+ require_relative "certs"
10
11
 
11
12
  module Neetob
12
13
  class CLI
@@ -43,6 +44,12 @@ module Neetob
43
44
  def maintenance_window
44
45
  MaintenanceWindow.new(options[:app]).process
45
46
  end
47
+
48
+ desc "certs", "Check the certificates of the app on Heroku"
49
+ option :app, type: :string, aliases: "-a", required: "true", desc: "Name of your app in Heroku"
50
+ def certs
51
+ Certs.new(options[:app]).process
52
+ end
46
53
  end
47
54
  end
48
55
  end
@@ -19,16 +19,25 @@ module Neetob
19
19
 
20
20
  def run
21
21
  matching_apps = find_all_matching_apps_or_repos(apps, :heroku, sandbox)
22
+ final_data = []
22
23
  matching_apps.each do |app|
23
- ui.info("\n Config of #{app}\n")
24
+ ui.info("\n Config of #{app}\n", print_to_audit_log: false)
24
25
  config = `heroku config -a #{app} --json`
25
26
  unless $?.success?
26
- ui.error("There is a problem in accessing the app with name \"#{app}\" in your account.")
27
- ui.error("Please check the specified app name and ensure you're authorized to view that app.")
27
+ ui.error(
28
+ "There is a problem in accessing the app with name \"#{app}\" in your account.",
29
+ print_to_audit_log: false)
30
+ ui.error(
31
+ "Please check the specified app name and ensure you're authorized to view that app.",
32
+ print_to_audit_log: false)
28
33
  next
29
34
  end
30
35
  table = Terminal::Table.new headings: table_columns, rows: filter_config(config)
31
- ui.success(table)
36
+ ui.success(table, print_to_audit_log: false)
37
+ final_data << JSON.parse(config)
38
+ end
39
+ if Thread.current[:audit_mode]
40
+ final_data
32
41
  end
33
42
  end
34
43
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "neeto_deploy/main"
3
+ require_relative "neeto_deploy_or_heroku/main"
4
4
  require_relative "cloudflare/main"
5
5
  require_relative "cronitor/main"
6
6
  require_relative "honeybadger/main"
@@ -17,9 +17,9 @@ module Neetob
17
17
  def run
18
18
  ui.success("# 3. Running audit for application instances and add-ons")
19
19
  ui.info "\n"
20
- ui.success("## 3.1. Checking NeetoDeploy related configurations")
20
+ ui.success("## 3.1. Checking NeetoDeploy/Heroku related configurations")
21
21
  ui.info "\n"
22
- NeetoDeploy::Main.new.run
22
+ NeetoDeployOrHeroku::Main.new.run
23
23
  ui.info "\n"
24
24
  ui.success("## 3.2. Checking Cloudflare related configurations")
25
25
  ui.info "\n"
@@ -4,7 +4,7 @@ module Neetob
4
4
  class CLI
5
5
  module MonthlyAudit
6
6
  module InstancesAndAddons
7
- module NeetoDeploy
7
+ module NeetoDeployOrHeroku
8
8
  class AutoScalingEnabled < CLI::Base
9
9
  def initialize
10
10
  super()
@@ -40,6 +40,17 @@ module Neetob
40
40
  end
41
41
  apps_data << [app, autoscaling_config, comments, audit_passed]
42
42
  end
43
+ Neetob::CLI::Sre::Base::APPS_LIST[:heroku].select { |app| app.include?("production") }.each do |app|
44
+ ui.info("Checking auto_scaling config for #{app}", print_to_audit_log: false)
45
+ autoscaling_config_result = Neetob::CLI::Heroku::AutoscalingConfig.new(app).run
46
+ comments = nil
47
+
48
+ audit_passed = autoscaling_config_result[:judoscale_addon_enabled] ? "Yes" : "No"
49
+ if audit_passed == "No"
50
+ comments = "Judoscale addon is not enabled"
51
+ end
52
+ apps_data << [app, autoscaling_config_result, comments, audit_passed]
53
+ end
43
54
  ui.print_table(apps_data)
44
55
  end
45
56
  end
@@ -4,7 +4,7 @@ module Neetob
4
4
  class CLI
5
5
  module MonthlyAudit
6
6
  module InstancesAndAddons
7
- module NeetoDeploy
7
+ module NeetoDeployOrHeroku
8
8
  class CloudfrontCdnEnabled < CLI::Base
9
9
  def initialize
10
10
  super()
@@ -46,6 +46,23 @@ module Neetob
46
46
  end
47
47
  apps_data << [app, asset_host_value, comments, audit_passed]
48
48
  end
49
+ Neetob::CLI::Sre::Base::APPS_LIST[:heroku].select { |app| app.include?("production") }.each do |app|
50
+ ui.info("Checking ASSET_HOST value for #{app}", print_to_audit_log: false)
51
+ config_vars_result = Neetob::CLI::Heroku::ConfigVars::List.new([app]).run[0]
52
+ asset_host_value = config_vars_result["ASSET_HOST"]
53
+ if asset_host_value.nil?
54
+ audit_passed = "No"
55
+ comments = "ASSET_HOST value not found."
56
+ else
57
+ is_direct_cloudfront_asset_host = asset_host_value.include?("cloudfront.net")
58
+ is_cdn_subdomain_asset_host = asset_host_value == "cdn.#{app.gsub("-web-production", "").gsub("-", "")}.com"
59
+ audit_passed = is_direct_cloudfront_asset_host || is_cdn_subdomain_asset_host ? "Yes" : "No"
60
+ if audit_passed == "No"
61
+ comments = "ASSET_HOST value is not a Cloudfront CDN URL or a CDN subdomain URL."
62
+ end
63
+ end
64
+ apps_data << [app, asset_host_value, comments, audit_passed]
65
+ end
49
66
  ui.print_table(apps_data)
50
67
  end
51
68
  end
@@ -4,7 +4,7 @@ module Neetob
4
4
  class CLI
5
5
  module MonthlyAudit
6
6
  module InstancesAndAddons
7
- module NeetoDeploy
7
+ module NeetoDeployOrHeroku
8
8
  class EssentialEnvironmentVariablesSet < CLI::Base
9
9
  def initialize
10
10
  super()
@@ -33,6 +33,16 @@ module Neetob
33
33
  end
34
34
  apps_data << [app, all_essential_env_variables_set, comments, audit_passed]
35
35
  end
36
+ Neetob::CLI::Sre::Base::APPS_LIST[:heroku].select { |app| app.include?("production") }.each do |app|
37
+ ui.info("Checking essential env variables for #{app}", print_to_audit_log: false)
38
+ essential_env_variables_result = Neetob::CLI::Sre::CheckEssentialEnv.new(app).run
39
+ all_essential_env_variables_set = essential_env_variables_result[:all_keys_present]
40
+ audit_passed = all_essential_env_variables_set ? "Yes" : "No"
41
+ if audit_passed == "No"
42
+ comments = "Missing keys: #{essential_env_variables_result[:missing_keys].join(", ")}"
43
+ end
44
+ apps_data << [app, all_essential_env_variables_set, comments, audit_passed]
45
+ end
36
46
  ui.print_table(apps_data)
37
47
  end
38
48
  end
@@ -10,7 +10,7 @@ module Neetob
10
10
  class CLI
11
11
  module MonthlyAudit
12
12
  module InstancesAndAddons
13
- module NeetoDeploy
13
+ module NeetoDeployOrHeroku
14
14
  class Main < CLI::Base
15
15
  def initialize
16
16
  super()
@@ -4,7 +4,7 @@ module Neetob
4
4
  class CLI
5
5
  module MonthlyAudit
6
6
  module InstancesAndAddons
7
- module NeetoDeploy
7
+ module NeetoDeployOrHeroku
8
8
  class ScheduledExportsEnabled < CLI::Base
9
9
  def initialize
10
10
  super()
@@ -4,7 +4,7 @@ module Neetob
4
4
  class CLI
5
5
  module MonthlyAudit
6
6
  module InstancesAndAddons
7
- module NeetoDeploy
7
+ module NeetoDeployOrHeroku
8
8
  class SslCertificatesOverThirtyDaysFromExpiry < CLI::Base
9
9
  def initialize
10
10
  super()
@@ -33,6 +33,21 @@ module Neetob
33
33
  end
34
34
  apps_data << [app, certificates_expiring_in_less_than_30_days, comments, audit_passed]
35
35
  end
36
+ Neetob::CLI::Sre::Base::APPS_LIST[:heroku].select { |app| app.include?("production") }.each do |app|
37
+ ui.info("Checking Certificates status for #{app}", print_to_audit_log: false)
38
+ certificates_status = Neetob::CLI::Heroku::Certs.new(app).run
39
+ certificates_expiring_in_less_than_30_days = certificates_status.select { |certificate| DateTime.parse(certificate[:expires]) <= 32.days.from_now }
40
+ comments = nil
41
+ audit_passed = "No"
42
+ certificates_expiring_in_less_than_30_days_present = "No"
43
+ if certificates_expiring_in_less_than_30_days.empty?
44
+ audit_passed = "Yes"
45
+ else
46
+ comments = "Certificates #{certificates_expiring_in_less_than_30_days.map { |certificate| certificate[:name] }.join(", ")} are expiring in less than 30 days."
47
+ certificates_expiring_in_less_than_30_days_present = "Yes"
48
+ end
49
+ apps_data << [app, certificates_expiring_in_less_than_30_days_present, comments, audit_passed]
50
+ end
36
51
  ui.print_table(apps_data)
37
52
  end
38
53
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Neetob
4
- VERSION = "0.5.29"
4
+ VERSION = "0.5.30"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neetob
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.29
4
+ version: 0.5.30
5
5
  platform: ruby
6
6
  authors:
7
7
  - Udai Gupta
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-22 00:00:00.000000000 Z
11
+ date: 2025-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -218,6 +218,7 @@ files:
218
218
  - lib/neetob/cli/heroku/access/remove.rb
219
219
  - lib/neetob/cli/heroku/autoscaling_config.rb
220
220
  - lib/neetob/cli/heroku/base.rb
221
+ - lib/neetob/cli/heroku/certs.rb
221
222
  - lib/neetob/cli/heroku/commands.rb
222
223
  - lib/neetob/cli/heroku/config_vars/audit.rb
223
224
  - lib/neetob/cli/heroku/config_vars/base.rb
@@ -248,12 +249,12 @@ files:
248
249
  - lib/neetob/cli/monthly_audit/instances_and_addons/honeybadger/main.rb
249
250
  - lib/neetob/cli/monthly_audit/instances_and_addons/honeybadger/setup_correctly_for_apps.rb
250
251
  - lib/neetob/cli/monthly_audit/instances_and_addons/main.rb
251
- - lib/neetob/cli/monthly_audit/instances_and_addons/neeto_deploy/auto_scaling_enabled.rb
252
- - lib/neetob/cli/monthly_audit/instances_and_addons/neeto_deploy/cloudfront_cdn_enabled.rb
253
- - lib/neetob/cli/monthly_audit/instances_and_addons/neeto_deploy/essential_environment_variables_set.rb
254
- - lib/neetob/cli/monthly_audit/instances_and_addons/neeto_deploy/main.rb
255
- - lib/neetob/cli/monthly_audit/instances_and_addons/neeto_deploy/scheduled_exports_enabled.rb
256
- - lib/neetob/cli/monthly_audit/instances_and_addons/neeto_deploy/ssl_certificates_over_thirty_days_from_expiry.rb
252
+ - lib/neetob/cli/monthly_audit/instances_and_addons/neeto_deploy_or_heroku/auto_scaling_enabled.rb
253
+ - lib/neetob/cli/monthly_audit/instances_and_addons/neeto_deploy_or_heroku/cloudfront_cdn_enabled.rb
254
+ - lib/neetob/cli/monthly_audit/instances_and_addons/neeto_deploy_or_heroku/essential_environment_variables_set.rb
255
+ - lib/neetob/cli/monthly_audit/instances_and_addons/neeto_deploy_or_heroku/main.rb
256
+ - lib/neetob/cli/monthly_audit/instances_and_addons/neeto_deploy_or_heroku/scheduled_exports_enabled.rb
257
+ - lib/neetob/cli/monthly_audit/instances_and_addons/neeto_deploy_or_heroku/ssl_certificates_over_thirty_days_from_expiry.rb
257
258
  - lib/neetob/cli/monthly_audit/misc/main.rb
258
259
  - lib/neetob/cli/monthly_audit/misc/redirections_working_correctly.rb
259
260
  - lib/neetob/cli/monthly_audit/misc/sparkpost_sub_account_used_for_all_apps.rb