Extract untested-payloads.log checker spec task action
MSP-11145 Extract the spec task action which errored out if `log/untested-payloads.log` exists to `Metasploit::Framework::Spec::UntestedPayloads.define_task`.bug/bundler_fix
parent
a7317cb86c
commit
f827a1c761
19
Rakefile
19
Rakefile
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env rake
|
||||
require File.expand_path('../config/application', __FILE__)
|
||||
require 'metasploit/framework/require'
|
||||
require 'metasploit/framework/spec/untested_payloads'
|
||||
|
||||
# @note must be before `Metasploit::Framework::Application.load_tasks`
|
||||
#
|
||||
|
@ -9,20 +10,4 @@ require 'metasploit/framework/require'
|
|||
Metasploit::Framework::Require.optionally_active_record_railtie
|
||||
|
||||
Metasploit::Framework::Application.load_tasks
|
||||
|
||||
# append action to run after normal spec action
|
||||
task :spec do
|
||||
untested_payloads_pathname = Pathname.new 'log/untested-payloads.log'
|
||||
|
||||
if untested_payloads_pathname.exist?
|
||||
$stderr.puts "Untested payload detected. Add tests to spec/modules/payload_spec.rb for payloads classes composed of the following payload modules:"
|
||||
|
||||
untested_payloads_pathname.open do |f|
|
||||
f.each_line do |line|
|
||||
$stderr.write " #{line}"
|
||||
end
|
||||
end
|
||||
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
Metasploit::Framework::Spec::UntestedPayloads.define_task
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
# @note needs to use explicit nesting. so this file can be loaded directly without loading 'metasploit/framework' which
|
||||
# allows for faster loading of rake tasks
|
||||
module Metasploit
|
||||
module Framework
|
||||
module Spec
|
||||
module UntestedPayloads
|
||||
# @note `Metasploit::Framework::Spec::UntestedPayloads.define_task` should be run after the normal spec task is
|
||||
# defined.
|
||||
#
|
||||
# Adds action to `spec` tasks so that `rake spec` fails if `log/untested-payloads.log` exists and prints out untested
|
||||
# payloads from that log to stderr.
|
||||
#
|
||||
# @return [void]
|
||||
def self.define_task
|
||||
Rake::Task.define_task :spec do
|
||||
untested_payloads_pathname = Pathname.new 'log/untested-payloads.log'
|
||||
|
||||
if untested_payloads_pathname.exist?
|
||||
$stderr.puts "Untested payload detected. Add tests to spec/modules/payload_spec.rb for payloads classes composed of the following payload modules:"
|
||||
|
||||
untested_payloads_pathname.open do |f|
|
||||
f.each_line do |line|
|
||||
$stderr.write " #{line}"
|
||||
end
|
||||
end
|
||||
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue