Skip to content
This repository was archived by the owner on Jan 24, 2022. It is now read-only.

Commit e3a01f8

Browse files
author
Jonathan Claudius
authored
Merge pull request #529 from mozilla/upgrade_rubies
Update rubies
2 parents 46ed50e + 9353adf commit e3a01f8

File tree

9 files changed

+133
-51
lines changed

9 files changed

+133
-51
lines changed

.travis.yml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,45 +11,52 @@ matrix:
1111
- LABEL=unit_tests
1212
after_success:
1313
- coveralls
14-
- rvm: 2.5.8
14+
- rvm: 2.6.7
1515
env:
1616
- LABEL=unit_tests
17-
- rvm: 2.6.6
17+
- rvm: 2.7.3
1818
env:
1919
- LABEL=unit_tests
20-
- rvm: 2.7.2
20+
- rvm: 3.0.1
2121
env:
2222
- LABEL=unit_tests
23-
- rvm: 2.5.8
23+
- rvm: 2.6.7
2424
env:
2525
- LABEL=gem_integration_tests
2626
script:
2727
- gem install ssh_scan
2828
- chmod 755 ./spec/ssh_scan/integration.sh
2929
- ./spec/ssh_scan/integration.sh
30-
- rvm: 2.6.6
30+
- rvm: 2.7.3
3131
env:
3232
- LABEL=gem_integration_tests
3333
script:
3434
- gem install ssh_scan
3535
- chmod 755 ./spec/ssh_scan/integration.sh
3636
- ./spec/ssh_scan/integration.sh
37-
- rvm: 2.7.2
37+
- rvm: 3.0.1
38+
env:
39+
- LABEL=gem_integration_tests
40+
script:
41+
- gem install ssh_scan
42+
- chmod 755 ./spec/ssh_scan/integration.sh
43+
- ./spec/ssh_scan/integration.sh
44+
- rvm: 2.7.3
3845
env:
3946
- LABEL=src_integration_tests
4047
script:
4148
- bundle install
4249
- chmod 755 ./spec/ssh_scan/integration.sh
4350
- ./spec/ssh_scan/integration.sh
44-
- rvm: 2.7.2
51+
- rvm: 3.0.1
4552
env:
4653
- LABEL=docker_integration_tests
4754
services:
4855
- docker
4956
script:
5057
- docker build -t mozilla/ssh_scan .
5158
- docker run -it mozilla/ssh_scan /app/spec/ssh_scan/integration.sh
52-
- rvm: 2.7.2
59+
- rvm: 3.0.1
5360
env:
5461
- LABEL=docker_build_and_push
5562
services:

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ruby:2.7.2-alpine3.12
1+
FROM ruby:3.0.1-alpine3.13
22
MAINTAINER Jonathan Claudius
33
ENV PROJECT=github.com/mozilla/ssh_scan
44

Gemfile.lock

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
PATH
2+
remote: .
3+
specs:
4+
ssh_scan (0.0.43)
5+
bcrypt_pbkdf (= 1.0.1)
6+
bindata (= 2.4.3)
7+
ed25519 (= 1.2.4)
8+
net-ssh (= 6.0.2)
9+
netaddr (= 2.0.4)
10+
sshkey
11+
12+
GEM
13+
remote: https://rubygems.org/
14+
specs:
15+
ast (2.4.2)
16+
bcrypt_pbkdf (1.0.1)
17+
bindata (2.4.3)
18+
coderay (1.1.3)
19+
coveralls (0.8.23)
20+
json (>= 1.8, < 3)
21+
simplecov (~> 0.16.1)
22+
term-ansicolor (~> 1.3)
23+
thor (>= 0.19.4, < 2.0)
24+
tins (~> 1.6)
25+
diff-lcs (1.4.4)
26+
docile (1.4.0)
27+
ed25519 (1.2.4)
28+
json (2.5.1)
29+
method_source (0.9.2)
30+
net-ssh (6.0.2)
31+
netaddr (2.0.4)
32+
parallel (1.20.1)
33+
parser (3.0.1.1)
34+
ast (~> 2.4.1)
35+
pry (0.11.3)
36+
coderay (~> 1.1.0)
37+
method_source (~> 0.9.0)
38+
rainbow (3.0.0)
39+
rake (13.0.3)
40+
regexp_parser (2.1.1)
41+
rexml (3.2.5)
42+
rspec (3.7.0)
43+
rspec-core (~> 3.7.0)
44+
rspec-expectations (~> 3.7.0)
45+
rspec-mocks (~> 3.7.0)
46+
rspec-core (3.7.1)
47+
rspec-support (~> 3.7.0)
48+
rspec-expectations (3.7.0)
49+
diff-lcs (>= 1.2.0, < 2.0)
50+
rspec-support (~> 3.7.0)
51+
rspec-its (1.2.0)
52+
rspec-core (>= 3.0.0)
53+
rspec-expectations (>= 3.0.0)
54+
rspec-mocks (3.7.0)
55+
diff-lcs (>= 1.2.0, < 2.0)
56+
rspec-support (~> 3.7.0)
57+
rspec-support (3.7.1)
58+
rubocop (1.15.0)
59+
parallel (~> 1.10)
60+
parser (>= 3.0.0.0)
61+
rainbow (>= 2.2.2, < 4.0)
62+
regexp_parser (>= 1.8, < 3.0)
63+
rexml
64+
rubocop-ast (>= 1.5.0, < 2.0)
65+
ruby-progressbar (~> 1.7)
66+
unicode-display_width (>= 1.4.0, < 3.0)
67+
rubocop-ast (1.5.0)
68+
parser (>= 3.0.1.1)
69+
ruby-progressbar (1.11.0)
70+
simplecov (0.16.1)
71+
docile (~> 1.1)
72+
json (>= 1.8, < 3)
73+
simplecov-html (~> 0.10.0)
74+
simplecov-html (0.10.2)
75+
sshkey (2.0.0)
76+
sync (0.5.0)
77+
term-ansicolor (1.7.1)
78+
tins (~> 1.0)
79+
thor (1.1.0)
80+
tins (1.29.1)
81+
sync
82+
unicode-display_width (2.0.0)
83+
84+
PLATFORMS
85+
ruby
86+
87+
DEPENDENCIES
88+
coveralls
89+
pry (= 0.11.3)
90+
rake (>= 12.3.3)
91+
rspec (= 3.7.0)
92+
rspec-its (= 1.2.0)
93+
rubocop
94+
ssh_scan!
95+
96+
BUNDLED WITH
97+
2.2.15

bin/ssh_scan

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
$:.unshift File.join(File.dirname(__FILE__), "../lib")
55

66
require 'json'
7-
require 'netaddr'
87
require 'optparse'
98
require 'ssh_scan'
109
require 'logger'

lib/ssh_scan/scan_engine.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def scan_target(socket, opts)
9898
target,
9999
:port => port,
100100
:timeout => timeout,
101-
:paranoid => false
101+
:verify_host_key => :never
102102
)
103103
raise SSHScan::Error::ClosedConnection.new if net_ssh_session.closed?
104104
auth_session = Net::SSH::Authentication::Session.new(

lib/ssh_scan/target_parser.rb

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class TargetParser
88
# @param ip [String] IP address
99
# @param port [Fixnum] port
1010
# @return [Array] array of enumerated addresses
11-
def enumerateIPRange(ip,port)
11+
def enumerateIPRange(ip,port=nil)
1212
if ip.fqdn?
1313
if port.nil?
1414
socket = ip
@@ -17,29 +17,22 @@ def enumerateIPRange(ip,port)
1717
end
1818
return [socket]
1919
else
20-
if ip.include? "-"
21-
octets = ip.split('.')
22-
range = octets.pop.split('-')
23-
lower = NetAddr::CIDR.create(octets.join('.') + "." + range[0])
24-
upper = NetAddr::CIDR.create(octets.join('.') + "." + range[1])
25-
ip_array = NetAddr.range(lower, upper,:Inclusive => true)
26-
if !port.nil?
27-
ip_array.map! { |i| i.concat(":").concat(port.to_s) }
28-
end
29-
return ip_array
30-
elsif ip.include? "/"
20+
if ip.include? "/"
3121
begin
32-
cidr = NetAddr::CIDR.create(ip)
22+
ip_net = NetAddr::IPv4Net.parse(ip)
3323
rescue
3424
raise ArgumentError, "Invalid target: #{ip}"
3525
end
36-
ip_array = cidr.enumerate
37-
ip_array.delete(cidr.network)
38-
ip_array.delete(cidr.last)
26+
27+
sock_array = []
28+
1.upto(ip_net.len - 2) do |i|
29+
sock_array << ip_net.nth(i).to_s
30+
end
31+
3932
if !port.nil?
40-
ip_array.map! { |i| i.concat(":").concat(port.to_s) }
33+
sock_array.map! { |i| i.concat(":").concat(port.to_s) }
4134
end
42-
return ip_array
35+
return sock_array
4336
else
4437
if port.nil?
4538
socket = ip

lib/string_ext.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ def resolve_fqdn_as_ipv4(timeout = 3)
5555
end
5656

5757
def resolve_fqdn
58-
TCPSocket.gethostbyname(self)[3]
58+
begin
59+
IPSocket.getaddress(self)
60+
rescue SocketError
61+
nil # Can return anything you want here
62+
end
5963
end
6064

6165
def resolve_ptr(timeout = 3)

spec/ssh_scan/target_parser_spec.rb

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,6 @@
3939
end
4040
end
4141

42-
context "IPv4 Range seperated by '-' without port" do
43-
it "should return an array containing all the IPv4 in that range" do
44-
target_parser = SSHScan::TargetParser.new()
45-
expect(target_parser.enumerateIPRange("192.168.1.1-2", nil)).to eq(
46-
["192.168.1.1", "192.168.1.2"]
47-
)
48-
end
49-
end
50-
51-
context "IPv4 Range seperated by '-' with port" do
52-
it "should return an array containing all the IPv4 in that range" do
53-
target_parser = SSHScan::TargetParser.new()
54-
expect(target_parser.enumerateIPRange("192.168.1.1-2", 33)).to eq(
55-
["192.168.1.1:33", "192.168.1.2:33"]
56-
)
57-
end
58-
end
59-
6042
context "IPv4 with subnet mask specified without port" do
6143
it "should return an array containing all the IPv4 in that range" do
6244
target_parser = SSHScan::TargetParser.new()

ssh_scan.gemspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ Gem::Specification.new do |s|
3131
s.metadata["yard.run"] = "yri" # use "yard" to build full HTML docs
3232

3333
s.add_dependency('bindata', '2.4.3')
34-
s.add_dependency('netaddr', '1.5.1')
35-
s.add_dependency('net-ssh', '5.2.0')
34+
s.add_dependency('netaddr', '2.0.4')
35+
s.add_dependency('net-ssh', '6.0.2')
3636
s.add_dependency('ed25519', '1.2.4')
3737
s.add_dependency('bcrypt_pbkdf', '1.0.1')
3838
s.add_dependency('sshkey')
3939
s.add_development_dependency('pry', '0.11.3')
4040
s.add_development_dependency('rspec', '3.7.0')
4141
s.add_development_dependency('rspec-its', '1.2.0')
42-
s.add_development_dependency('rake', '12.3.1')
42+
s.add_development_dependency "rake", ">= 12.3.3"
4343
s.add_development_dependency('rubocop')
4444
end

0 commit comments

Comments
 (0)