Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/metasploit/framework/spec/untested_payloads.rb
Views: 11784
# @note needs to use explicit nesting. so this file can be loaded directly without loading 'metasploit/framework' which1# allows for faster loading of rake tasks.2module Metasploit3module Framework4module Spec5module UntestedPayloads6# @note `Metasploit::Framework::Spec::UntestedPayloads.define_task` should be run after the normal spec task is7# defined.8#9# Adds action to `spec` tasks so that `rake spec` fails if `log/untested-payloads.log` exists and prints out untested10# payloads from that log to stderr.11#12# # @example Using `Metasploit::Framework::Spec::UntestedPayloads.define_task` with 'payload can be instantiated' shared examples and 'untested payloads' shared context13# # Rakefile14# require 'metasploit/framework/spec/untested_payloads'15#16# # defined spec task with rspec-rails17# My::Application.load_tasks18# # extends spec task to fail when there are untested payloads19# Metasploit::Framework::Spec::UntestedPayloads.define_task20#21# # spec/modules/payloads_spec.rb22# require 'spec_helper'23#24# describe 'modules/payloads' do25# modules_pathname = Pathname.new(__FILE__).parent.parent.parent.join('modules')26#27# include_context 'untested payloads', modules_pathname: modules_pathname28#29# context 'my/staged/payload/handler' do30# it_should_behave_like 'payload can be instantiated',31# ancestor_reference_names: [32# 'stages/my/payload',33# 'stagers/my/payload/handler'34# ],35# modules_pathname: modules_pathname,36# reference_name: 'my/staged/payload/handler'37# end38# end39#40# @return [void]41def self.define_task42Rake::Task.define_task :spec do43untested_payloads_pathname = Pathname.new 'log/untested-payloads.log'4445if untested_payloads_pathname.exist?46tool_path = 'tools/modules/missing_payload_tests.rb'4748$stderr.puts "Untested payload detected. Running `#{tool_path}` to see contexts to add to " \49"`spec/modules/payloads_spec.rb` to test those payload ancestor reference names."5051system(tool_path)5253exit 154end55end56end57end58end59end60end616263