7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/fuzzer/cli.rb', line 7
def self.start(argv)
url = argv.shift
data = YAML::load_file("config.yml");
if data['secret_access_key'].nil? || data['access_key_id'].nil?
puts "In this directory, create a config.yml file with the Amazon secret_access_key: <value> and access_key_id: <value>"
exit(1)
end
if (url.nil?)
puts "Usage: bundle exec fuzzer <url>"
exit(1)
end
unless url =~ /^#{URI::regexp}$/
puts "I'm not seeing a valid URL here: #{url}"
exit(1)
end
begin
file_name = download(url)
short_name = gunzip(file_name)
puts "We can corrupt this database two ways:"
puts " easy: only currupt data that would come from the feed"
puts " severe: also corrupt db integrity and delete nodes"
begin
print "e)asy or s)evere? "
input = gets.chomp
end while (input != "e" && input != "s")
puts "Working on it..."
db = SQLite3::Database.new(short_name)
fuzz_content(db)
fuzz_integrity(db) if input == "s"
final_name = gzip(short_name)
upload(data, final_name)
rescue Exception => e
puts "Well, that didn't end well: #{e.message}"
end
end
|