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 +4 -4
- data/lib/specinfra/command/module/ss.rb +10 -6
- data/lib/specinfra/version.rb +1 -1
- data/spec/command/amazon2/port_spec.rb +1 -1
- data/spec/command/debian8/port_spec.rb +1 -1
- data/spec/command/debian9/port_spec.rb +1 -1
- data/spec/command/module/ss_spec.rb +15 -15
- data/spec/command/redhat7/port_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbb0d81c432decaa53c81f134c822c02b1f2c8bf
|
4
|
+
data.tar.gz: 15b2dd6d6b4852a3ef0266de005b786095e076a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
7
|
-
|
8
|
-
|
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
|
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
|
|
data/lib/specinfra/version.rb
CHANGED
@@ -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
|
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.
|
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-
|
11
|
+
date: 2019-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-scp
|