Class: Fuzzer::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/fuzzer/cli.rb

Class Method Summary collapse

Class Method Details

.start(argv) ⇒ Object



4
5
6
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
# File 'lib/fuzzer/cli.rb', line 4

def self.start(argv)
    url = argv.shift
    
    data = YAML::load(File.read("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 = CLI.download(url)
        short_name = CLI.gunzip(file_name)
        
        # manipulate it
        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")
        
        db = SQLite3::Database.new(short_name)
        CLI.fuzz_content(db)
        CLI.fuzz_integrity(db) if input == "s"
        
        # Query as to what should be broken?
        final_name = CLI.gzip(short_name)
        upload(data, final_name)
    rescue Exception => e
        puts "Well, that didn't end well: #{e.message}"
    end
end