rex-socket 0.1.16 → 0.1.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4bdb4cd1c80f682ba03ce203c85aba6fa1d6f097
4
- data.tar.gz: 17547f6431af31a89a5ef92618460c3837ecb0f1
3
+ metadata.gz: 24fd1f504f256379c0d5d2edd6784c3023f56f03
4
+ data.tar.gz: f173a85b8a8fcb821f45be200c8a1704caeeca77
5
5
  SHA512:
6
- metadata.gz: 8ab1f746dfca5ce6329f51ae3675415a11c949eb65fd9adf47dce42276e5d0f8d1cf8ea7e6deac20405f4d41f948736f50e333117a979e3d8b277015b92cd8b6
7
- data.tar.gz: 3ed9c24becb764bfc92d6cf06eabb9e0c36d0e7cd5c614cafa7e8d44b6549390f1c35ad49c5bc04f72380ec17b4b2e2565a16cc5f23a33b3f59ac8b9a7fe091f
6
+ metadata.gz: d3c3e16ee50aa43e3d96c6f41bb9b41541b24160839890dd1edb842e32e264141102be75d02778491593f830c2fb3e1a2af8485e5f68a81178758b9e2840374e
7
+ data.tar.gz: 7d09132d390ff1cccaf0c66b485239d059a7959c0e68e2553b48305b7a02b8546fc2afbcc734d436bd67bd22046a115ea61ace6a710f15ed4539bcb8fc116d1f
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -79,8 +79,21 @@ class RangeWalker
79
79
  parseme.split(', ').map{ |a| a.split(' ') }.flatten.each do |arg|
80
80
  opts = {}
81
81
 
82
- # Handle IPv6 first (support ranges, but not CIDR)
83
- if arg.include?(":")
82
+ # Handle IPv6 CIDR first
83
+ if arg.include?(':') && arg.include?('/')
84
+ return false if !valid_cidr_chars?(arg)
85
+
86
+ ip_part, mask_part = arg.split("/")
87
+ return false unless (0..128).include? mask_part.to_i
88
+
89
+ addr, scope_id = ip_part.split('%')
90
+ return false unless Rex::Socket.is_ipv6?(addr)
91
+
92
+ range = expand_cidr(addr + '/' + mask_part)
93
+ range.options[:scope_id] = scope_id if scope_id
94
+ ranges.push(range)
95
+ # Handle plain IPv6 next (support ranges, but not CIDR)
96
+ elsif arg.include?(':')
84
97
  addrs = arg.split('-', 2)
85
98
 
86
99
  # Handle a single address
@@ -97,8 +110,9 @@ class RangeWalker
97
110
 
98
111
  addr1, scope_id = addrs[0].split('%')
99
112
  opts[:scope_id] = scope_id if scope_id
113
+ opts[:ipv6] = true
100
114
 
101
- addr2, scope_id = addrs[0].split('%')
115
+ addr2, scope_id = addrs[1].split('%')
102
116
  ( opts[:scope_id] ||= scope_id ) if scope_id
103
117
 
104
118
  # Both have to be IPv6 for this to work
@@ -114,12 +128,9 @@ class RangeWalker
114
128
  # Handle IPv4 CIDR
115
129
  elsif arg.include?("/")
116
130
  # Then it's CIDR notation and needs special case
117
- return false if arg =~ /[,-]/ # Improper CIDR notation (can't mix with 1,3 or 1-3 style IP ranges)
118
- return false if arg.scan("/").size > 1 # ..but there are too many slashes
119
- ip_part,mask_part = arg.split("/")
120
- return false if ip_part.nil? or ip_part.empty? or mask_part.nil? or mask_part.empty?
121
- return false if mask_part !~ /^[0-9]{1,2}$/ # Illegal mask -- numerals only
122
- return false if mask_part.to_i > 32 # This too -- between 0 and 32.
131
+ return false if !valid_cidr_chars?(arg)
132
+ ip_part, mask_part = arg.split("/")
133
+ return false unless (0..32).include? mask_part.to_i
123
134
  if ip_part =~ /^\d{1,3}(\.\d{1,3}){1,3}$/
124
135
  return false unless ip_part =~ Rex::Socket::MATCH_IPV4
125
136
  end
@@ -417,6 +428,17 @@ class RangeWalker
417
428
  return ranges
418
429
  end
419
430
 
431
+ protected
432
+
433
+ def valid_cidr_chars?(arg)
434
+ return false if arg.include? ',-' # Improper CIDR notation (can't mix with 1,3 or 1-3 style IP ranges)
435
+ return false if arg.scan("/").size > 1 # ..but there are too many slashes
436
+ ip_part, mask_part = arg.split("/")
437
+ return false if ip_part.nil? || ip_part.empty? || mask_part.nil? || mask_part.empty?
438
+ return false if mask_part !~ /^[0-9]{1,3}$/ # Illegal mask -- numerals only
439
+ true
440
+ end
441
+
420
442
  end
421
443
 
422
444
  # A range of IP addresses
@@ -1,5 +1,5 @@
1
1
  module Rex
2
2
  module Socket
3
- VERSION = "0.1.16"
3
+ VERSION = "0.1.17"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rex-socket
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.16
4
+ version: 0.1.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Maloney
@@ -88,7 +88,7 @@ cert_chain:
88
88
  G+Hmcg1v810agasPdoydE0RTVZgEOOMoQ07qu7JFXVWZ9ZQpHT7qJATWL/b2csFG
89
89
  8mVuTXnyJOKRJA==
90
90
  -----END CERTIFICATE-----
91
- date: 2019-02-14 00:00:00.000000000 Z
91
+ date: 2019-02-27 00:00:00.000000000 Z
92
92
  dependencies:
93
93
  - !ruby/object:Gem::Dependency
94
94
  name: bundler
metadata.gz.sig CHANGED
Binary file