specinfra 2.76.7 → 2.76.8

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: 4cd763fdd6237b7dbac88091ea30e7f658fafdaf
4
- data.tar.gz: c587f5b0de1d32d946d74399ac2e086e05c0c974
3
+ metadata.gz: bbb0d81c432decaa53c81f134c822c02b1f2c8bf
4
+ data.tar.gz: 15b2dd6d6b4852a3ef0266de005b786095e076a4
5
5
  SHA512:
6
- metadata.gz: e4a3b1e452d9b30f2cdaa9dedb689aaf209c01515a0eaf38a8327906a835ec3b4b062c74b54f0ddab53f22a55fa721c7c0f10fe9b0f07a0d7e8d10fb536cfb4d
7
- data.tar.gz: b5ce08ff8dd4af0b243be065cc5703f4fbd98549659a651764d918b6f7672b9626935a77029e3450ab3bac009156a029b7c26c8cdd5758fa0b0d42083ae422cc
6
+ metadata.gz: ed6ff5efe632a627760b539416e4813087eb49642dc9b6d97fe62ffa5aa57a4eff52d8761ca51e117115fc136c8950c7a5862caadb319fc36d9cc6d79e54a7eb
7
+ data.tar.gz: 95aec2a203b72a1c4b799a428fdabc1905bf7f58b3d45148573f023368ab886251a813589e3be161c9f3dc29dd2ebc94df7cd22a81350bade727b3498bd08911
@@ -3,22 +3,26 @@ module Specinfra
3
3
  module Module
4
4
  module Ss
5
5
  def check_is_listening(port, options={})
6
- pattern = ":#{port} "
7
- pattern = " #{inaddr_any_to_asterisk(options[:local_address])}#{pattern}" if options[:local_address]
8
- "ss #{command_options(options[:protocol])} | grep -- #{escape(pattern)}"
6
+ if options[:local_address]
7
+ pattern = inaddr_any_to_asterisk(options[:local_address]).map { |l| " #{l}:#{port} " }
8
+ pattern = pattern.join('|')
9
+ else
10
+ pattern = ":#{port} "
11
+ end
12
+ "ss #{command_options(options[:protocol])} | grep -E -- #{escape(pattern)}"
9
13
  end
10
14
 
11
15
  private
12
16
 
13
17
  # WORKAROUND:
14
- # ss displays "*" instead of "0.0.0.0".
18
+ # Older ss versions display "*" instead of "0.0.0.0".
15
19
  # But serverspec validates IP address by `valid_ip_address?` method:
16
20
  # https://github.com/serverspec/serverspec/blob/master/lib/serverspec/type/port.rb
17
21
  def inaddr_any_to_asterisk(local_address)
18
22
  if local_address == '0.0.0.0'
19
- '\*'
23
+ [ '\*' , '0\.0\.0\.0' ]
20
24
  else
21
- local_address
25
+ [ local_address ]
22
26
  end
23
27
  end
24
28
 
@@ -1,3 +1,3 @@
1
1
  module Specinfra
2
- VERSION = "2.76.7"
2
+ VERSION = "2.76.8"
3
3
  end
@@ -4,5 +4,5 @@ property[:os] = nil
4
4
  set :os, :family => 'amazon', :release => '2'
5
5
 
6
6
  describe get_command(:check_port_is_listening, '80') do
7
- it { should eq 'ss -tunl | grep -- :80\ ' }
7
+ it { should eq 'ss -tunl | grep -E -- :80\ ' }
8
8
  end
@@ -4,5 +4,5 @@ property[:os] = nil
4
4
  set :os, :family => 'debian', :release => '8'
5
5
 
6
6
  describe get_command(:check_port_is_listening, '80') do
7
- it { should eq 'ss -tunl | grep -- :80\ ' }
7
+ it { should eq 'ss -tunl | grep -E -- :80\ ' }
8
8
  end
@@ -4,6 +4,6 @@ property[:os] = nil
4
4
  set :os, :family => 'debian', :release => '9'
5
5
 
6
6
  describe get_command(:check_port_is_listening, '80') do
7
- it { should eq 'ss -tunl | grep -- :80\ ' }
7
+ it { should eq 'ss -tunl | grep -E -- :80\ ' }
8
8
  end
9
9
 
@@ -5,24 +5,24 @@ describe Specinfra::Command::Module::Ss do
5
5
  extend Specinfra::Command::Module::Ss
6
6
  end
7
7
  let(:klass) { Specinfra::Command::Module::Ss::Test }
8
- it { expect(klass.check_is_listening('80')).to eq 'ss -tunl | grep -- :80\ ' }
8
+ it { expect(klass.check_is_listening('80')).to eq 'ss -tunl | grep -E -- :80\ ' }
9
9
 
10
- it { expect(klass.check_is_listening('80', options={:protocol => 'tcp'})).to eq 'ss -tnl4 | grep -- :80\ ' }
11
- it { expect(klass.check_is_listening('80', options={:protocol => 'tcp6'})).to eq 'ss -tnl6 | grep -- :80\ ' }
12
- it { expect(klass.check_is_listening('80', options={:protocol => 'udp'})).to eq 'ss -unl4 | grep -- :80\ ' }
13
- it { expect(klass.check_is_listening('80', options={:protocol => 'udp6'})).to eq 'ss -unl6 | grep -- :80\ ' }
10
+ it { expect(klass.check_is_listening('80', options={:protocol => 'tcp'})).to eq 'ss -tnl4 | grep -E -- :80\ ' }
11
+ it { expect(klass.check_is_listening('80', options={:protocol => 'tcp6'})).to eq 'ss -tnl6 | grep -E -- :80\ ' }
12
+ it { expect(klass.check_is_listening('80', options={:protocol => 'udp'})).to eq 'ss -unl4 | grep -E -- :80\ ' }
13
+ it { expect(klass.check_is_listening('80', options={:protocol => 'udp6'})).to eq 'ss -unl6 | grep -E -- :80\ ' }
14
14
 
15
- it { expect(klass.check_is_listening('80', options={:local_address => '0.0.0.0'})).to eq 'ss -tunl | grep -- \ \\\\\*:80\ ' }
16
- it { expect(klass.check_is_listening('80', options={:local_address => '0.0.0.0', :protocol => 'tcp'})).to eq 'ss -tnl4 | grep -- \ \\\\\*:80\ ' }
17
- it { expect(klass.check_is_listening('80', options={:local_address => '0.0.0.0', :protocol => 'tcp6'})).to eq 'ss -tnl6 | grep -- \ \\\\\*:80\ ' }
18
- it { expect(klass.check_is_listening('80', options={:local_address => '0.0.0.0', :protocol => 'udp'})).to eq 'ss -unl4 | grep -- \ \\\\\*:80\ ' }
19
- it { expect(klass.check_is_listening('80', options={:local_address => '0.0.0.0', :protocol => 'udp6'})).to eq 'ss -unl6 | grep -- \ \\\\\*:80\ ' }
15
+ it { expect(klass.check_is_listening('80', options={:local_address => '0.0.0.0'})).to eq 'ss -tunl | grep -E -- \ \\\\\*:80\ \\|\\ 0\\\\.0\\\\.0\\\\.0:80\\ ' }
16
+ it { expect(klass.check_is_listening('80', options={:local_address => '0.0.0.0', :protocol => 'tcp'})).to eq 'ss -tnl4 | grep -E -- \ \\\\\*:80\ \\|\\ 0\\\\.0\\\\.0\\\\.0:80\\ ' }
17
+ it { expect(klass.check_is_listening('80', options={:local_address => '0.0.0.0', :protocol => 'tcp6'})).to eq 'ss -tnl6 | grep -E -- \ \\\\\*:80\ \\|\\ 0\\\\.0\\\\.0\\\\.0:80\\ ' }
18
+ it { expect(klass.check_is_listening('80', options={:local_address => '0.0.0.0', :protocol => 'udp'})).to eq 'ss -unl4 | grep -E -- \ \\\\\*:80\ \\|\\ 0\\\\.0\\\\.0\\\\.0:80\\ ' }
19
+ it { expect(klass.check_is_listening('80', options={:local_address => '0.0.0.0', :protocol => 'udp6'})).to eq 'ss -unl6 | grep -E -- \ \\\\\*:80\ \\|\\ 0\\\\.0\\\\.0\\\\.0:80\\ ' }
20
20
 
21
- it { expect(klass.check_is_listening('80', options={:local_address => '1.2.3.4'})).to eq 'ss -tunl | grep -- \ 1.2.3.4:80\ ' }
22
- it { expect(klass.check_is_listening('80', options={:local_address => '1.2.3.4', :protocol => 'tcp'})).to eq 'ss -tnl4 | grep -- \ 1.2.3.4:80\ ' }
23
- it { expect(klass.check_is_listening('80', options={:local_address => '1.2.3.4', :protocol => 'tcp6'})).to eq 'ss -tnl6 | grep -- \ 1.2.3.4:80\ ' }
24
- it { expect(klass.check_is_listening('80', options={:local_address => '1.2.3.4', :protocol => 'udp'})).to eq 'ss -unl4 | grep -- \ 1.2.3.4:80\ ' }
25
- it { expect(klass.check_is_listening('80', options={:local_address => '1.2.3.4', :protocol => 'udp6'})).to eq 'ss -unl6 | grep -- \ 1.2.3.4:80\ ' }
21
+ it { expect(klass.check_is_listening('80', options={:local_address => '1.2.3.4'})).to eq 'ss -tunl | grep -E -- \ 1.2.3.4:80\ ' }
22
+ it { expect(klass.check_is_listening('80', options={:local_address => '1.2.3.4', :protocol => 'tcp'})).to eq 'ss -tnl4 | grep -E -- \ 1.2.3.4:80\ ' }
23
+ it { expect(klass.check_is_listening('80', options={:local_address => '1.2.3.4', :protocol => 'tcp6'})).to eq 'ss -tnl6 | grep -E -- \ 1.2.3.4:80\ ' }
24
+ it { expect(klass.check_is_listening('80', options={:local_address => '1.2.3.4', :protocol => 'udp'})).to eq 'ss -unl4 | grep -E -- \ 1.2.3.4:80\ ' }
25
+ it { expect(klass.check_is_listening('80', options={:local_address => '1.2.3.4', :protocol => 'udp6'})).to eq 'ss -unl6 | grep -E -- \ 1.2.3.4:80\ ' }
26
26
 
27
27
  it { expect{klass.check_is_listening('80', options={:protocol => 'bad_proto'})}.to raise_error(ArgumentError, 'Unknown protocol [bad_proto]') }
28
28
  end
@@ -4,5 +4,5 @@ property[:os] = nil
4
4
  set :os, :family => 'redhat', :release => '7'
5
5
 
6
6
  describe get_command(:check_port_is_listening, '80') do
7
- it { should eq 'ss -tunl | grep -- :80\ ' }
7
+ it { should eq 'ss -tunl | grep -E -- :80\ ' }
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: specinfra
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.76.7
4
+ version: 2.76.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gosuke Miyashita
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-09 00:00:00.000000000 Z
11
+ date: 2019-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-scp