class Ronin::ArtifactRunner
Public Class Methods
new()
click to toggle source
# File lib/ronin/artifact_runner.rb, line 26 def initialize @changes = false @run_list = Ronin::RunList.new end
Public Instance Methods
download_and_report_changes()
click to toggle source
# File lib/ronin/artifact_runner.rb, line 31 def download_and_report_changes @items = @run_list.items Parallel.each(@items, :in_threads => Ronin::Util.num_cores) do |item| @actual_branch = Ronin::Git.branch(item[:name]) if File.exist?("#{Ronin::Config[:artifact_path]}/#{item[:name]}") if item[:branch] != 'master' Ronin::Log.info("Module #{item[:name]} is being pulled from the #{item[:branch]} branch and not master.") end if @actual_branch == item[:branch] Ronin::Log.info("Module #{item[:name]} already cached, pulling updates to #{item[:branch]} from #{item[:repo]}.") @updated = Ronin::Git.pull_and_report_updated(item[:name]) if @updated Ronin::Log.info("Module #{item[:name]} has updates.") @changes = true if Ronin::Config[:update_on_change] end else Ronin::Log.info("Module #{item[:name]} already cached, but is the wrong branch. Deleting cached copy of branch #{@actual_branch}") FileUtils.rm_rf("#{Ronin::Config[:artifact_path]}/#{item[:name]}/") Ronin::Git.clone(item) @changes = true if Ronin::Config[:update_on_change] end else Ronin::Log.info("Module #{item[:name]} not cached, cloning branch #{item[:branch]} of #{item[:repo]} to #{Ronin::Config[:artifact_path]}.") Ronin::Git.clone(item) @changes = true if Ronin::Config[:update_on_change] end end @changes end
purge_unused()
click to toggle source
# File lib/ronin/artifact_runner.rb, line 63 def purge_unused @local_artifacts = Dir.entries(Ronin::Config[:artifact_path]).select { |dir| File.directory?("#{Ronin::Config[:artifact_path]}/#{dir}") and !(dir =='.' || dir == '..') } @artifacts = @run_list.artifacts @local_artifacts.each do |a| unless @artifacts.include?(a) Ronin::Log.info("No module named #{a} in run list, but it exists in #{Ronin::Config[:artifact_path]}. Purging it.") FileUtils.rm_rf("#{Ronin::Config[:artifact_path]}/#{a}/") end end end