Skip to content

Commit

Permalink
ignore sleeps
Browse files Browse the repository at this point in the history
  • Loading branch information
h00die committed Dec 21, 2024
1 parent 80d15ae commit 262e4b8
Showing 1 changed file with 25 additions and 26 deletions.
51 changes: 25 additions & 26 deletions spec/lib/msf/core/post/linux/busy_box_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: binary -*-
require 'spec_helper'

require 'spec_helper'

RSpec.describe Msf::Post::Linux::BusyBox do
subject do
Expand All @@ -9,15 +9,15 @@
mod
end

describe "#busy_box_file_exist?" do
describe "when file exists" do
describe '#busy_box_file_exist?' do
describe 'when file exists' do
before :example do
allow(subject).to receive(:read_file) do
'test data'
end
end

it "returns true" do
it 'returns true' do
expect(subject.busy_box_file_exist?('/etc/passwd')).to be_truthy
end
end
Expand All @@ -29,20 +29,21 @@
end
end

it "returns false" do
it 'returns false' do
expect(subject.busy_box_file_exist?('/etc/nonexistent')).to be_falsey
end
end
end

describe "#busy_box_is_writable_dir?" do
describe '#busy_box_is_writable_dir?' do
before :example do
allow(subject).to receive(:cmd_exec) do
''
end
allow(Rex).to receive(:sleep)
end

describe "when dir is writable" do
describe 'when dir is writable' do
before :example do
allow(subject).to receive(:read_file) do
"#{'A' * 16}XXX#{'A' * 16}"
Expand All @@ -53,7 +54,7 @@
end
end

it "returns true" do
it 'returns true' do
expect(subject.busy_box_is_writable_dir?('/tmp/')).to be_truthy
end
end
Expand All @@ -65,14 +66,13 @@
end
end

it "returns false" do
it 'returns false' do
expect(subject.busy_box_is_writable_dir?('/etc/')).to be_falsey
end
end
end


describe "#busy_box_writable_dir" do
describe '#busy_box_writable_dir' do
before :example do
allow(subject).to receive(:cmd_exec) do
''
Expand All @@ -86,12 +86,12 @@
end
end

it "returns nil" do
it 'returns nil' do
expect(subject.busy_box_writable_dir).to be_nil
end
end

describe "when a writable directory exists" do
describe 'when a writable directory exists' do
before :example do
allow(subject).to receive(:read_file) do
"#{'A' * 16}XXX#{'A' * 16}"
Expand All @@ -102,18 +102,18 @@
end
end

it "returns the writable dir path" do
it 'returns the writable dir path' do
expect(subject.busy_box_writable_dir).to eq('/etc/')
end
end
end


describe "#busy_box_write_file" do
describe '#busy_box_write_file' do
before :example do
allow(subject).to receive(:cmd_exec) do
''
end
allow(Rex).to receive(:sleep)
end

describe "when the file isn't writable" do
Expand All @@ -123,12 +123,12 @@
end
end

it "returns false" do
it 'returns false' do
expect(subject.busy_box_write_file('/etc/passwd', 'test')).to be_falsey
end
end

describe "when the file is writable" do
describe 'when the file is writable' do
before :example do
allow(subject).to receive(:read_file) do
"#{'A' * 16}XXX#{'A' * 16}"
Expand All @@ -139,14 +139,14 @@
end
end

it "returns true" do
it 'returns true' do
expect(subject.busy_box_write_file('/tmp/test', 'test')).to be_truthy
end
end

describe "when prepend is true" do
describe "when there is a writable dir" do
describe "when the target file is writable" do
describe 'when prepend is true' do
describe 'when there is a writable dir' do
describe 'when the target file is writable' do
before :example do
allow(subject).to receive(:busy_box_writable_dir) do
'/tmp/'
Expand All @@ -161,7 +161,7 @@
end
end

it "returns true" do
it 'returns true' do
expect(subject.busy_box_write_file('/tmp/test', 'test', true)).to be_truthy
end
end
Expand All @@ -173,12 +173,11 @@
nil
end
end
it "returns false" do

it 'returns false' do
expect(subject.busy_box_write_file('/tmp/test', 'test', true)).to be_falsey
end
end
end
end

end

0 comments on commit 262e4b8

Please sign in to comment.