Class: TrackSuccessfulExploits

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
db/migrate/20110513143900_track_successful_exploits.rb

Defined Under Namespace

Classes: ExploitedHost, Vuln

Class Method Summary collapse

Class Method Details

.downObject



27
28
29
# File 'db/migrate/20110513143900_track_successful_exploits.rb', line 27

def self.down
	remove_column :vulns, :exploited_at
end

.upObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'db/migrate/20110513143900_track_successful_exploits.rb', line 10

def self.up
	add_column :vulns, :exploited_at, :timestamp

	# Migrate existing exploited_hosts entries

	ExploitedHost.find(:all).select {|x| x.name}.each do |exploited_host|
		next unless(exploited_host.name =~ /^(exploit|auxiliary)\//)
		vulns = Vuln.find_all_by_name_and_host_id(exploited_host.name, exploited_host.host_id)
		next if vulns.empty?
		vulns.each do |vuln|
			vuln.exploited_at = exploited_host.updated_at
			vuln.save
		end
	end
	
end