Skip to content
This repository was archived by the owner on Oct 22, 2020. It is now read-only.

Commit c8f0da1

Browse files
committed
Add #before_store method
1 parent ca2171c commit c8f0da1

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/wpxf/wordpress/stored_xss.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ def store_script_and_validate
4040
false
4141
end
4242

43+
# Execute all tasks required before storing the script.
44+
# @return [Boolean] return true if the prerequisite actions were successfully executed.
45+
def before_store
46+
true
47+
end
48+
4349
# @return [Number] The status code that is expected after storing the script.
4450
def expected_status_code_after_store
4551
200
@@ -48,7 +54,7 @@ def expected_status_code_after_store
4854
# Run the module.
4955
# @return [Boolean] true if successful.
5056
def run
51-
return false unless super
57+
return false unless super && before_store
5258

5359
emit_info 'Storing script...'
5460
return false unless store_script_and_validate

spec/wordpress/stored_xss_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@
3232
subject.run
3333
expect(invoked).to be true
3434
end
35+
36+
it 'returns false if #before_store returns false' do
37+
allow(subject).to receive(:before_store).and_return false
38+
allow(subject).to receive(:puts).and_return nil
39+
allow(subject).to receive(:check_wordpress_and_online).and_return true
40+
allow(subject).to receive(:start_http_server).and_return true
41+
42+
expect(subject.run).to be false
43+
end
3544
end
3645

3746
describe '#store_script' do

0 commit comments

Comments
 (0)