diff --git a/spec/lib/msf/core/post/linux/kernel_spec.rb b/spec/lib/msf/core/post/linux/kernel_spec.rb index 704ff9a82474..84b26bd795d5 100644 --- a/spec/lib/msf/core/post/linux/kernel_spec.rb +++ b/spec/lib/msf/core/post/linux/kernel_spec.rb @@ -8,105 +8,104 @@ end describe '#uname' do - context 'it returns an ubuntu kernel' do - it 'returns the kernel information' do - allow(subject).to receive(:cmd_exec).and_return('Linux kali 6.11.2-amd64 #1 SMP PREEMPT_DYNAMIC Kali 6.11.2-1kali1 (2024-10-15) x86_64 GNU/Linux ') - expect(subject.uname).to eq('Linux kali 6.11.2-amd64 #1 SMP PREEMPT_DYNAMIC Kali 6.11.2-1kali1 (2024-10-15) x86_64 GNU/Linux') + context 'it returns an ubuntu kernel' do + it 'returns the kernel information' do + allow(subject).to receive(:cmd_exec).and_return('Linux kali 6.11.2-amd64 #1 SMP PREEMPT_DYNAMIC Kali 6.11.2-1kali1 (2024-10-15) x86_64 GNU/Linux ') + expect(subject.uname).to eq('Linux kali 6.11.2-amd64 #1 SMP PREEMPT_DYNAMIC Kali 6.11.2-1kali1 (2024-10-15) x86_64 GNU/Linux') + end end end - end describe '#kernel_release' do - context 'it returns an ubuntu kernel release' do - it 'returns 6.11.2-amd64' do - allow(subject).to receive(:cmd_exec).and_return('6.11.2-amd64 ') - expect(subject.kernel_release).to eq('6.11.2-amd64') + context 'it returns an ubuntu kernel release' do + it 'returns 6.11.2-amd64' do + allow(subject).to receive(:cmd_exec).and_return('6.11.2-amd64 ') + expect(subject.kernel_release).to eq('6.11.2-amd64') + end end end - end describe '#kernel_version' do - context 'it returns an ubuntu kernel version' do - it 'returns 6.11.2-amd64' do - allow(subject).to receive(:cmd_exec).and_return('#1 SMP PREEMPT_DYNAMIC Kali 6.11.2-1kali1 (2024-10-15) ') - expect(subject.kernel_version).to eq('#1 SMP PREEMPT_DYNAMIC Kali 6.11.2-1kali1 (2024-10-15)') + context 'it returns an ubuntu kernel version' do + it 'returns 6.11.2-amd64' do + allow(subject).to receive(:cmd_exec).and_return('#1 SMP PREEMPT_DYNAMIC Kali 6.11.2-1kali1 (2024-10-15) ') + expect(subject.kernel_version).to eq('#1 SMP PREEMPT_DYNAMIC Kali 6.11.2-1kali1 (2024-10-15)') + end end end - end describe '#kernel_name' do - context 'it returns an ubuntu kernel name' do - it 'returns Linux' do - allow(subject).to receive(:cmd_exec).and_return('Linux ') - expect(subject.kernel_name).to eq('Linux') + context 'it returns an ubuntu kernel name' do + it 'returns Linux' do + allow(subject).to receive(:cmd_exec).and_return('Linux ') + expect(subject.kernel_name).to eq('Linux') + end end end - end describe '#kernel_hardware' do - context 'it returns an ubuntu kernel hardware' do - it 'returns x86_64' do - allow(subject).to receive(:cmd_exec).and_return('x86_64 ') - expect(subject.kernel_hardware).to eq('x86_64') + context 'it returns an ubuntu kernel hardware' do + it 'returns x86_64' do + allow(subject).to receive(:cmd_exec).and_return('x86_64 ') + expect(subject.kernel_hardware).to eq('x86_64') + end end end - end describe '#kernel_arch' do - context 'it returns an ubuntu kernel arch' do - it 'returns x64' do - allow(subject).to receive(:cmd_exec).and_return('x86_64 ') - expect(subject.kernel_arch).to eq('x64') - end - it 'returns aarch64' do - allow(subject).to receive(:cmd_exec).and_return('aarch64 ') - expect(subject.kernel_arch).to eq('aarch64') - end - it 'returns aarch64' do - allow(subject).to receive(:cmd_exec).and_return('arm ') - expect(subject.kernel_arch).to eq('armle') - end - it 'returns x86' do - allow(subject).to receive(:cmd_exec).and_return('i686 ') - expect(subject.kernel_arch).to eq('x86') - end - it 'returns ppc' do - allow(subject).to receive(:cmd_exec).and_return('ppc ') - expect(subject.kernel_arch).to eq('ppc') - end - it 'returns ppc64' do - allow(subject).to receive(:cmd_exec).and_return('ppc64 ') - expect(subject.kernel_arch).to eq('ppc64') + context 'it returns an ubuntu kernel arch' do + it 'returns x64' do + allow(subject).to receive(:cmd_exec).and_return('x86_64 ') + expect(subject.kernel_arch).to eq('x64') + end + it 'returns aarch64' do + allow(subject).to receive(:cmd_exec).and_return('aarch64 ') + expect(subject.kernel_arch).to eq('aarch64') + end + it 'returns aarch64' do + allow(subject).to receive(:cmd_exec).and_return('arm ') + expect(subject.kernel_arch).to eq('armle') + end + it 'returns x86' do + allow(subject).to receive(:cmd_exec).and_return('i686 ') + expect(subject.kernel_arch).to eq('x86') + end + it 'returns ppc' do + allow(subject).to receive(:cmd_exec).and_return('ppc ') + expect(subject.kernel_arch).to eq('ppc') + end + it 'returns ppc64' do + allow(subject).to receive(:cmd_exec).and_return('ppc64 ') + expect(subject.kernel_arch).to eq('ppc64') + end + it 'returns ppc64le' do + allow(subject).to receive(:cmd_exec).and_return('ppc64le ') + expect(subject.kernel_arch).to eq('ppc64le') + end + it 'returns mips' do + allow(subject).to receive(:cmd_exec).and_return('mips ') + expect(subject.kernel_arch).to eq('mips') + end + it 'returns mips64' do + allow(subject).to receive(:cmd_exec).and_return('mips64 ') + expect(subject.kernel_arch).to eq('mips64') + end + it 'returns sparc' do + allow(subject).to receive(:cmd_exec).and_return('sparc ') + expect(subject.kernel_arch).to eq('sparc') + end + it 'returns riscv32le' do + allow(subject).to receive(:cmd_exec).and_return('riscv32 ') + expect(subject.kernel_arch).to eq('riscv32le') + end + it 'returns riscv64le' do + allow(subject).to receive(:cmd_exec).and_return('riscv64 ') + expect(subject.kernel_arch).to eq('riscv64le') + end + it 'returns loongarch64' do + allow(subject).to receive(:cmd_exec).and_return('loongarch64 ') + expect(subject.kernel_arch).to eq('loongarch64') + end end - it 'returns ppc64le' do - allow(subject).to receive(:cmd_exec).and_return('ppc64le ') - expect(subject.kernel_arch).to eq('ppc64le') - end - it 'returns mips' do - allow(subject).to receive(:cmd_exec).and_return('mips ') - expect(subject.kernel_arch).to eq('mips') - end - it 'returns mips64' do - allow(subject).to receive(:cmd_exec).and_return('mips64 ') - expect(subject.kernel_arch).to eq('mips64') - end - it 'returns sparc' do - allow(subject).to receive(:cmd_exec).and_return('sparc ') - expect(subject.kernel_arch).to eq('sparc') - end - it 'returns riscv32le' do - allow(subject).to receive(:cmd_exec).and_return('riscv32 ') - expect(subject.kernel_arch).to eq('riscv32le') - end - it 'returns riscv64le' do - allow(subject).to receive(:cmd_exec).and_return('riscv64 ') - expect(subject.kernel_arch).to eq('riscv64le') - end - it 'returns loongarch64' do - allow(subject).to receive(:cmd_exec).and_return('loongarch64 ') - expect(subject.kernel_arch).to eq('loongarch64') - end - - end end -end \ No newline at end of file +end diff --git a/spec/lib/msf/core/post/linux/packages_spec.rb b/spec/lib/msf/core/post/linux/packages_spec.rb index 438a2d0fb69a..2e7f16138695 100644 --- a/spec/lib/msf/core/post/linux/packages_spec.rb +++ b/spec/lib/msf/core/post/linux/packages_spec.rb @@ -10,14 +10,14 @@ describe '#installed_package_version' do context 'when the OS isnt supported' do it 'returns nil' do - allow(subject).to receive(:get_sysinfo).and_return({:kernel=>"", :distro=>"unsupported", :version=>""}) + allow(subject).to receive(:get_sysinfo).and_return({ kernel: '', distro: 'unsupported', version: '' }) expect(subject.installed_package_version('test')).to be_nil end end context 'when the Ubuntu/Debian package isnt installed' do it 'returns nil' do - allow(subject).to receive(:get_sysinfo).and_return({:kernel=>"Linux ubuntu22 5.15.0-25-generic #25-Ubuntu SMP Wed Mar 30 15:54:22 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux", :distro=>"ubuntu", :version=>"Ubuntu 22.04.5 LTS"}) + allow(subject).to receive(:get_sysinfo).and_return({ kernel: 'Linux ubuntu22 5.15.0-25-generic #25-Ubuntu SMP Wed Mar 30 15:54:22 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux', distro: 'ubuntu', version: 'Ubuntu 22.04.5 LTS' }) allow(subject).to receive(:cmd_exec).and_return('dpkg-query: no packages found matching example') expect(subject.installed_package_version('test')).to be_nil end @@ -25,7 +25,7 @@ context 'when the Ubuntu/Debian package is installed' do it 'returns 3.5-5ubuntu2.1' do - allow(subject).to receive(:get_sysinfo).and_return({:kernel=>"Linux ubuntu22 5.15.0-25-generic #25-Ubuntu SMP Wed Mar 30 15:54:22 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux", :distro=>"ubuntu", :version=>"Ubuntu 22.04.5 LTS"}) + allow(subject).to receive(:get_sysinfo).and_return({ kernel: 'Linux ubuntu22 5.15.0-25-generic #25-Ubuntu SMP Wed Mar 30 15:54:22 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux', distro: 'ubuntu', version: 'Ubuntu 22.04.5 LTS' }) allow(subject).to receive(:cmd_exec).and_return('3.5-5ubuntu2.1') expect(subject.installed_package_version('test')).to eq(Rex::Version.new('3.5-5ubuntu2.1')) end @@ -33,49 +33,49 @@ context 'when the Ubuntu/Debian package is installed with a + in the version number' do it 'returns 1.34.dfsg.pre.1ubuntu0.1.22.04.2' do - allow(subject).to receive(:get_sysinfo).and_return({:kernel=>"Linux ubuntu22 5.15.0-25-generic #25-Ubuntu SMP Wed Mar 30 15:54:22 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux", :distro=>"ubuntu", :version=>"Ubuntu 22.04.5 LTS"}) + allow(subject).to receive(:get_sysinfo).and_return({ kernel: 'Linux ubuntu22 5.15.0-25-generic #25-Ubuntu SMP Wed Mar 30 15:54:22 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux', distro: 'ubuntu', version: 'Ubuntu 22.04.5 LTS' }) allow(subject).to receive(:cmd_exec).and_return('1.34+dfsg-1ubuntu0.1.22.04.2') - expect(subject.installed_package_version('test')).to eq(Rex::Version.new("1.34.dfsg.pre.1ubuntu0.1.22.04.2")) + expect(subject.installed_package_version('test')).to eq(Rex::Version.new('1.34.dfsg.pre.1ubuntu0.1.22.04.2')) end end context 'when distro is redhat or fedora' do it 'returns the package version' do - allow(subject).to receive(:get_sysinfo).and_return({:kernel=>"", :distro=>"redhat", :version=>""}) + allow(subject).to receive(:get_sysinfo).and_return({ kernel: '', distro: 'redhat', version: '' }) allow(subject).to receive(:cmd_exec).and_return('curl-8.2.1-3.fc39.x86_64') - expect(subject.installed_package_version('curl')).to eq(Rex::Version.new('8.2.1-3.fc39')) + expect(subject.installed_package_version('curl')).to eq(Rex::Version.new('8.2.1-3.fc39')) end end - + context 'when distro is solaris' do it 'returns the package version' do - allow(subject).to receive(:get_sysinfo).and_return({:kernel=>"", :distro=>"solaris", :version=>""}) + allow(subject).to receive(:get_sysinfo).and_return({ kernel: '', distro: 'solaris', version: '' }) allow(subject).to receive(:cmd_exec).and_return('State: Installed\nVersion: 1.2.3') - expect(subject.installed_package_version('test')).to eq(Rex::Version.new('1.2.3')) + expect(subject.installed_package_version('test')).to eq(Rex::Version.new('1.2.3')) end end - + context 'when distro is freebsd' do it 'returns the package version' do - allow(subject).to receive(:get_sysinfo).and_return({:kernel=>"", :distro=>"freebsd", :version=>""}) + allow(subject).to receive(:get_sysinfo).and_return({ kernel: '', distro: 'freebsd', version: '' }) allow(subject).to receive(:cmd_exec).and_return('Version : 1.2.3') - expect(subject.installed_package_version('test')).to eq(Rex::Version.new('1.2.3')) + expect(subject.installed_package_version('test')).to eq(Rex::Version.new('1.2.3')) end end - + context 'when distro is gentoo' do it 'returns the package version' do - allow(subject).to receive(:get_sysinfo).and_return({:kernel=>"", :distro=>"gentoo", :version=>""}) + allow(subject).to receive(:get_sysinfo).and_return({ kernel: '', distro: 'gentoo', version: '' }) allow(subject).to receive(:cmd_exec).and_return('sys-devel/gcc-4.3.2-r3') - expect(subject.installed_package_version('test')).to eq(Rex::Version.new('4.3.2-r3')) + expect(subject.installed_package_version('test')).to eq(Rex::Version.new('4.3.2-r3')) end end - + context 'when distro is arch' do it 'returns the package version' do - allow(subject).to receive(:get_sysinfo).and_return({:kernel=>"", :distro=>"arch", :version=>""}) + allow(subject).to receive(:get_sysinfo).and_return({ kernel: '', distro: 'arch', version: '' }) allow(subject).to receive(:cmd_exec).and_return('Version : 1.2.3') - expect(subject.installed_package_version('test')).to eq(Rex::Version.new('1.2.3')) + expect(subject.installed_package_version('test')).to eq(Rex::Version.new('1.2.3')) end end end diff --git a/spec/lib/msf/core/post/linux/priv_spec.rb b/spec/lib/msf/core/post/linux/priv_spec.rb index 2f0dbcf68c15..c54268fb9756 100644 --- a/spec/lib/msf/core/post/linux/priv_spec.rb +++ b/spec/lib/msf/core/post/linux/priv_spec.rb @@ -32,111 +32,111 @@ end describe '#cp_cmd' do - it 'copies the content of one file to another' do - origin_file = '/path/to/origin' - final_file = '/path/to/destination' - file_content = 'file content' + it 'copies the content of one file to another' do + origin_file = '/path/to/origin' + final_file = '/path/to/destination' + file_content = 'file content' - allow(subject).to receive(:read_file).with(origin_file).and_return(file_content) - expect(subject).to receive(:cmd_exec).with("echo '#{file_content}' > '#{final_file}'") + allow(subject).to receive(:read_file).with(origin_file).and_return(file_content) + expect(subject).to receive(:cmd_exec).with("echo '#{file_content}' > '#{final_file}'") - subject.cp_cmd(origin_file, final_file) + subject.cp_cmd(origin_file, final_file) + end end -end -describe '#binary_of_pid' do - it 'retrieves the binary name of a process given its PID' do - pid = 1234 - cmdline_content = '/usr/bin/bash' - comm_content = 'bash' + describe '#binary_of_pid' do + it 'retrieves the binary name of a process given its PID' do + pid = 1234 + cmdline_content = '/usr/bin/bash' + comm_content = 'bash' - allow(subject).to receive(:read_file).with("/proc/#{pid}/cmdline").and_return(cmdline_content) - expect(subject.binary_of_pid(pid)).to eq('/usr/bin/bash') + allow(subject).to receive(:read_file).with("/proc/#{pid}/cmdline").and_return(cmdline_content) + expect(subject.binary_of_pid(pid)).to eq('/usr/bin/bash') - allow(subject).to receive(:read_file).with("/proc/#{pid}/cmdline").and_return('') - allow(subject).to receive(:read_file).with("/proc/#{pid}/comm").and_return(comm_content) - expect(subject.binary_of_pid(pid)).to eq('bash') + allow(subject).to receive(:read_file).with("/proc/#{pid}/cmdline").and_return('') + allow(subject).to receive(:read_file).with("/proc/#{pid}/comm").and_return(comm_content) + expect(subject.binary_of_pid(pid)).to eq('bash') + end end -end -describe '#seq' do - it 'generates a sequence of numbers from first to last with a given increment' do - expect(subject.seq(1, 2, 10)).to eq([1, 3, 5, 7, 9]) - expect(subject.seq(0, 5, 20)).to eq([0, 5, 10, 15, 20]) + describe '#seq' do + it 'generates a sequence of numbers from first to last with a given increment' do + expect(subject.seq(1, 2, 10)).to eq([1, 3, 5, 7, 9]) + expect(subject.seq(0, 5, 20)).to eq([0, 5, 10, 15, 20]) + end end -end -describe '#wc_cmd' do - it 'returns the number of lines, words, and characters in a file' do - file = '/path/to/file' - allow(subject).to receive(:nlines_file).with(file).and_return(10) - allow(subject).to receive(:nwords_file).with(file).and_return(20) - allow(subject).to receive(:nchars_file).with(file).and_return(100) + describe '#wc_cmd' do + it 'returns the number of lines, words, and characters in a file' do + file = '/path/to/file' + allow(subject).to receive(:nlines_file).with(file).and_return(10) + allow(subject).to receive(:nwords_file).with(file).and_return(20) + allow(subject).to receive(:nchars_file).with(file).and_return(100) - expect(subject.wc_cmd(file)).to eq([10, 20, 100, file]) + expect(subject.wc_cmd(file)).to eq([10, 20, 100, file]) + end end -end -describe '#nchars_file' do - it 'returns the number of characters in a file' do - file = '/path/to/file' - file_content = "Hello\nWorld" - allow(subject).to receive(:read_file).with(file).and_return(file_content) + describe '#nchars_file' do + it 'returns the number of characters in a file' do + file = '/path/to/file' + file_content = "Hello\nWorld" + allow(subject).to receive(:read_file).with(file).and_return(file_content) - # agrees with wc - # $ echo -n "Hello\nWorld" | wc -m - # 12 - expect(subject.nchars_file(file)).to eq(12) + # agrees with wc + # $ echo -n "Hello\nWorld" | wc -m + # 12 + expect(subject.nchars_file(file)).to eq(12) + end end -end -describe '#nwords_file' do - it 'returns the number of words in a file' do - file = '/path/to/file' - file_content = "Hello World\nThis is a test" - allow(subject).to receive(:read_file).with(file).and_return(file_content) + describe '#nwords_file' do + it 'returns the number of words in a file' do + file = '/path/to/file' + file_content = "Hello World\nThis is a test" + allow(subject).to receive(:read_file).with(file).and_return(file_content) - expect(subject.nwords_file(file)).to eq(6) + expect(subject.nwords_file(file)).to eq(6) + end end -end -describe '#nlines_file' do - it 'returns the number of lines in a file' do - file = '/path/to/file' - file_content = "Hello\nWorld\nThis is a test" - allow(subject).to receive(:read_file).with(file).and_return(file_content) + describe '#nlines_file' do + it 'returns the number of lines in a file' do + file = '/path/to/file' + file_content = "Hello\nWorld\nThis is a test" + allow(subject).to receive(:read_file).with(file).and_return(file_content) - expect(subject.nlines_file(file)).to eq(3) + expect(subject.nlines_file(file)).to eq(3) + end end -end -describe '#head_cmd' do - it 'returns the first n lines of a file' do - file = '/path/to/file' - file_content = "Line 1\nLine 2\nLine 3\nLine 4\nLine 5" - allow(subject).to receive(:read_file).with(file).and_return(file_content) + describe '#head_cmd' do + it 'returns the first n lines of a file' do + file = '/path/to/file' + file_content = "Line 1\nLine 2\nLine 3\nLine 4\nLine 5" + allow(subject).to receive(:read_file).with(file).and_return(file_content) - expect(subject.head_cmd(file, 3)).to eq(["Line 1", "Line 2", "Line 3"]) + expect(subject.head_cmd(file, 3)).to eq(['Line 1', 'Line 2', 'Line 3']) + end end -end -describe '#tail_cmd' do - it 'returns the last n lines of a file' do - file = '/path/to/file' - file_content = "Line 1\nLine 2\nLine 3\nLine 4\nLine 5" - allow(subject).to receive(:read_file).with(file).and_return(file_content) + describe '#tail_cmd' do + it 'returns the last n lines of a file' do + file = '/path/to/file' + file_content = "Line 1\nLine 2\nLine 3\nLine 4\nLine 5" + allow(subject).to receive(:read_file).with(file).and_return(file_content) - expect(subject.tail_cmd(file, 3)).to eq(["Line 3", "Line 4", "Line 5"]) + expect(subject.tail_cmd(file, 3)).to eq(['Line 3', 'Line 4', 'Line 5']) + end end -end -describe '#grep_cmd' do - it 'searches for a specific string in a file and returns the lines that contain the string' do - file = '/path/to/file' - file_content = "Hello World\nThis is a test\nHello again" - allow(subject).to receive(:read_file).with(file).and_return(file_content) + describe '#grep_cmd' do + it 'searches for a specific string in a file and returns the lines that contain the string' do + file = '/path/to/file' + file_content = "Hello World\nThis is a test\nHello again" + allow(subject).to receive(:read_file).with(file).and_return(file_content) - expect(subject.grep_cmd(file, 'Hello')).to eq(["Hello World", "Hello again"]) + expect(subject.grep_cmd(file, 'Hello')).to eq(['Hello World', 'Hello again']) + end end end -end \ No newline at end of file diff --git a/spec/lib/msf/core/post/linux/process_spec.rb b/spec/lib/msf/core/post/linux/process_spec.rb index 52b96b5b75a7..8c9da1a54894 100644 --- a/spec/lib/msf/core/post/linux/process_spec.rb +++ b/spec/lib/msf/core/post/linux/process_spec.rb @@ -34,4 +34,4 @@ expect(result).to eq(memory_content) end end -end \ No newline at end of file +end diff --git a/spec/lib/msf/core/post/linux/system_spec.rb b/spec/lib/msf/core/post/linux/system_spec.rb index 17853685313f..66be7a3691b0 100644 --- a/spec/lib/msf/core/post/linux/system_spec.rb +++ b/spec/lib/msf/core/post/linux/system_spec.rb @@ -238,7 +238,7 @@ context 'when there are no permission denied errors' do it 'returns the list of SUID files' do suid_files = "/usr/bin/passwd\n/usr/bin/sudo\n" - allow(subject).to receive(:cmd_exec).with("find / -perm -4000 -print -xdev").and_return(suid_files) + allow(subject).to receive(:cmd_exec).with('find / -perm -4000 -print -xdev').and_return(suid_files) result = subject.get_suid_files @@ -249,7 +249,7 @@ context 'when there are permission denied errors' do it 'filters out the permission denied errors' do suid_files = "/usr/bin/passwd\nfind: ‘/root’: Permission denied\n/usr/bin/sudo\n" - allow(subject).to receive(:cmd_exec).with("find / -perm -4000 -print -xdev").and_return(suid_files) + allow(subject).to receive(:cmd_exec).with('find / -perm -4000 -print -xdev').and_return(suid_files) result = subject.get_suid_files @@ -259,13 +259,13 @@ context 'when an error occurs' do it 'raises an error' do - allow(subject).to receive(:cmd_exec).with("find / -perm -4000 -print -xdev").and_raise(StandardError) + allow(subject).to receive(:cmd_exec).with('find / -perm -4000 -print -xdev').and_raise(StandardError) expect { subject.get_suid_files }.to raise_error('Could not retrieve all SUID files') end end end - + describe '#get_path' do it 'returns the system path' do allow(subject).to receive(:cmd_exec).with('echo $PATH').and_return('/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin') @@ -526,7 +526,7 @@ allow(subject).to receive(:file?).with('/run/.containerenv').and_return(false) allow(subject).to receive(:directory?).with('/dev/lxc').and_return(false) allow(subject).to receive(:file?).with('/proc/sys/kernel/osrelease').and_return(true) - allow(subject).to receive(:read_file).with('/proc/sys/kernel/osrelease').and_return(["4.4.0-19041-Microsoft"]) + allow(subject).to receive(:read_file).with('/proc/sys/kernel/osrelease').and_return(['4.4.0-19041-Microsoft']) allow(subject).to receive(:report_host) expect(subject.get_container_type).to eq('WSL') end @@ -565,4 +565,4 @@ expect(subject.get_container_type).to eq('Unknown') end end -end \ No newline at end of file +end