firespring_dev_commands 2.2.6 → 2.2.8.pre.alpha.0

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: 56fe86ccb0ca1d53e766dfaf1672413ba8c47090a9e3ec1c507fa8c05137d0e3
4
- data.tar.gz: d429d3695666f2a1e910adf4c3f23568ec538007df64c2c74192eee6d1debdea
3
+ metadata.gz: b5dee68fee762c895021357261186dbf043c9719c2304c3d79893d943f83b10b
4
+ data.tar.gz: 9df30efd116a01d8688d1cfa5f61a12c3a8b871d797bd028da51f38c05c6e044
5
5
  SHA512:
6
- metadata.gz: fb92670bc256da6e80cfb26c611dfee20afdf4faf7a17161a4692b1840af550190d33714a63f1bf330d42d0e909cf1a1d98bbf9aa0c71bdf0ab16173c5bb3052
7
- data.tar.gz: 382a5c6197a223bed6d96e5500c0b48f04cff564eaf19fc30f985b882b36813e0130ed1d2ebc4dfcfd73eb9d8f8abbd9d7df4aebee379a62957b4a97c8abb9e0
6
+ metadata.gz: 8140c7df5ccc1b41e74959476d71708687175c5797dcfe4117934e7dbcce55edbaa98c957685209309c5c2582a1a858fe1b0d90e6898d08287b680b12c46b706
7
+ data.tar.gz: 3003314d63a53c06e6509c45b9e35eb2135a5b7b8a7ea8bc14039c86b062cb9f31a8ee27f22db216c5a117a6c2a39046a381695e821d469bd7b2d9a4090407fc
@@ -94,7 +94,7 @@ module Dev
94
94
  # because some projects may be using older versions of the dev_commands library
95
95
  # defaultini.delete('mfa_serial')
96
96
 
97
- session_name_default = defaultini['role_session_name'] || "#{ENV.fetch('USERNAME', nil)}_cli"
97
+ session_name_default = defaultini['role_session_name'] || "#{ENV.fetch('USERNAME', 'no_username_found')}_cli"
98
98
  defaultini['role_session_name'] = Dev::Common.new.ask('Default session name', session_name_default)
99
99
 
100
100
  duration_default = defaultini['session_duration'] || 36_000
@@ -61,7 +61,7 @@ module Dev
61
61
  puts " Logging in to #{account} in #{region} as #{role}".light_yellow
62
62
  puts
63
63
 
64
- code = ENV['AWS_TOKEN_CODE'] || Dev::Common.new.ask("Enter the MFA code for the #{ENV.fetch('USERNAME', '')} user serial #{serial}")
64
+ code = ENV['AWS_TOKEN_CODE'] || Dev::Common.new.ask("Enter the MFA code for the #{ENV.fetch('USERNAME', 'no_username_found')} user serial #{serial}")
65
65
  raise 'MFA is required' unless code.to_s.strip
66
66
 
67
67
  sts = ::Aws::STS::Client.new(profile: 'default', region:)
@@ -67,18 +67,56 @@ module Dev
67
67
  [response.hosted_zone, response.delegation_set]
68
68
  end
69
69
 
70
- def list_zone_details
70
+ def json_details
71
+ zone_count = 0
71
72
  zones do |zone|
72
- puts
73
73
  zone_details, delegation_set = details(zone.id)
74
74
  dns_resource = Dev::Dns::Resource.new(zone_details.name)
75
+ zone_count += 1
76
+ apex_record = dns_resource.recursive_a_lookup
77
+ nameserver_names = dns_resource.recursive_nameserver_lookup
78
+ nameserver_ips = nameserver_names.sort.map { |it| dns_resource.recursive_a_lookup(it) }
79
+ # Check if the site is dead, no a record or any AWS ips in the lists.
80
+ # if apex_record.empty? && (!zone_details.name.chomp('.').include? 'firespring') && (!nameserver_ips.join(', ').include? '205.251')
81
+ if !dns_resource.recursive_a_lookup.empty? && (dns_resource.recursive_nameserver_lookup.include? 'ns1.firespring.com')
82
+ out_data = {
83
+ 'count' => zone_count,
84
+ 'dns_name' => zone_details.name.chomp('.'),
85
+ 'hosted_zone_id' => zone_details.id,
86
+ 'delegation_set_id' => delegation_set.id,
87
+ # 'registrar_servers' => dns_resource.registrar_lookup.join(','), # This function is fickle, add with care.
88
+ 'reported_nameservers' => nameserver_names.sort.join(', '),
89
+ 'reported_ns_ips' => nameserver_ips.join(', '),
90
+ 'a_record_ip' => apex_record.sort.join(', ')
91
+ }
92
+ # Display contents
93
+ puts JSON.pretty_generate(out_data)
94
+ end
95
+ rescue ::Aws::Route53::Errors::Throttling
96
+ sleep(1)
97
+ retry
98
+ end
99
+ puts
100
+ end
75
101
 
76
- puts "#{zone_details.name.chomp('.').light_white} (#{zone_details.id}):"
77
- puts format(' %-50s %s', 'Delegation Set:', delegation_set.id)
78
- puts format(' %-50s %s', 'Delegation Defined Nameservers:', delegation_set.name_servers.sort.join(', '))
79
- puts format(' %-50s %s', 'DNS Reported Nameservers:', dns_resource.recursive_nameserver_lookup.sort.join(', '))
80
- puts format(' %-50s %s', 'DNS Reported Nameserver IPs:', dns_resource.recursive_nameserver_lookup.sort.map { |it| dns_resource.recursive_a_lookup(it) }.join(', '))
81
- puts format(' %-50s %s', 'Domain Apex IP Resolution:', dns_resource.recursive_a_lookup.sort.join(', '))
102
+ def command_line_details
103
+ zone_count = 0
104
+ zones do |zone|
105
+ zone_details, delegation_set = details(zone.id)
106
+ dns_resource = Dev::Dns::Resource.new(zone_details.name)
107
+ zone_count += 1
108
+ if !dns_resource.recursive_a_lookup.empty? && (dns_resource.recursive_nameserver_lookup.include? 'ns1.firespring.com')
109
+ puts
110
+ puts "#{zone_count} - #{zone_details.name.chomp('.')} (#{zone_details.id}):"
111
+ puts format(' %-50s %s', 'Delegation Set:', delegation_set.id)
112
+ puts format(' %-50s %s', 'Delegation Defined Nameservers:', delegation_set.name_servers.sort.join(', '))
113
+ puts format(' %-50s %s', 'WHOIS Reported server:', dns_resource.registrar_lookup.join(','))
114
+ puts format(' %-50s %s', 'DNS Reported Nameservers:', dns_resource.recursive_nameserver_lookup.sort.join(', '))
115
+ puts format(' %-50s %s', 'DNS Reported Nameserver IPs:', dns_resource.recursive_nameserver_lookup.sort.map do |it|
116
+ dns_resource.recursive_a_lookup(it)
117
+ end.join(', '))
118
+ puts format(' %-50s %s', 'Domain Apex IP Resolution:', dns_resource.recursive_a_lookup.sort.join(', '))
119
+ end
82
120
  rescue ::Aws::Route53::Errors::Throttling
83
121
  sleep(1)
84
122
  retry
@@ -1,3 +1,5 @@
1
+ require 'whois'
2
+
1
3
  module Dev
2
4
  class Dns
3
5
  class Resource
@@ -22,6 +24,14 @@ module Dev
22
24
  value.match?(Resolv::IPv6::Regex)
23
25
  end
24
26
 
27
+ # Determines the registrar(s) of the given name. Not perfect and can be rate limited.
28
+ def registrar_lookup(name = domain)
29
+ Whois.whois(name.chomp('.')).parts.map(&:host)
30
+ rescue Whois::Error
31
+ sleep(0.75)
32
+ retry
33
+ end
34
+
25
35
  # Recursively determine the correct nameservers for the given domain.
26
36
  # If nameservers are not found, strip subdomains off until we've reached the TLD
27
37
  def recursive_nameserver_lookup(name = domain)
@@ -6,7 +6,7 @@ module Dev
6
6
  module Services
7
7
  # Class contains rake templates for managing your AWS settings and logging in
8
8
  class Route53 < Dev::Template::BaseInterface
9
- def create_list_zone_details_task!
9
+ def create_pretty_list_zone_details_task!
10
10
  # Have to set a local variable to be accessible inside of the instance_eval block
11
11
  exclude = @exclude
12
12
 
@@ -18,7 +18,26 @@ module Dev
18
18
  desc 'print details for all hosted zones'
19
19
  task list_details: %w(ensure_aws_credentials) do
20
20
  route53 = Dev::Aws::Route53.new(ENV['DOMAINS'].to_s.strip.split(','))
21
- route53.list_zone_details
21
+ route53.command_line_details
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ def create_json_list_zone_details_task!
29
+ # Have to set a local variable to be accessible inside of the instance_eval block
30
+ exclude = @exclude
31
+
32
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
33
+ return if exclude.include?(:json_details)
34
+
35
+ namespace :aws do
36
+ namespace :hosted_zone do
37
+ desc 'print details for all hosted zones'
38
+ task json_details: %w(ensure_aws_credentials) do
39
+ route53 = Dev::Aws::Route53.new(ENV['DOMAINS'].to_s.strip.split(','))
40
+ route53.json_details
22
41
  end
23
42
  end
24
43
  end
@@ -6,6 +6,6 @@ module Dev
6
6
  # Use 'v.v.v.pre.alpha.v' for pre-release vesions
7
7
  # Use 'v.v.v.beta.v for beta versions
8
8
  # Use semantic versioning for any releases (https://semver.org/)
9
- VERSION = '2.2.6'.freeze
9
+ VERSION = '2.2.8.pre.alpha.0'.freeze
10
10
  end
11
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: firespring_dev_commands
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.6
4
+ version: 2.2.8.pre.alpha.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Firespring
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-16 00:00:00.000000000 Z
11
+ date: 2024-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -360,6 +360,20 @@ dependencies:
360
360
  - - "~>"
361
361
  - !ruby/object:Gem::Version
362
362
  version: 2.2.0
363
+ - !ruby/object:Gem::Dependency
364
+ name: whois
365
+ requirement: !ruby/object:Gem::Requirement
366
+ requirements:
367
+ - - "~>"
368
+ - !ruby/object:Gem::Version
369
+ version: '6.0'
370
+ type: :runtime
371
+ prerelease: false
372
+ version_requirements: !ruby/object:Gem::Requirement
373
+ requirements:
374
+ - - "~>"
375
+ - !ruby/object:Gem::Version
376
+ version: '6.0'
363
377
  description: Ruby library for creating/maintaining your development environment
364
378
  email: opensource@firespring.com
365
379
  executables: []
@@ -475,9 +489,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
475
489
  version: '3.1'
476
490
  required_rubygems_version: !ruby/object:Gem::Requirement
477
491
  requirements:
478
- - - ">="
492
+ - - ">"
479
493
  - !ruby/object:Gem::Version
480
- version: '0'
494
+ version: 1.3.1
481
495
  requirements: []
482
496
  rubygems_version: 3.4.10
483
497
  signing_key: