Class: Arachni::UI::Web::Log

Inherits:
Object
  • Object
show all
Defined in:
lib/arachni/ui/web/log.rb

Overview

A simple logger using DataMapper

@author: Tasos “Zapotek” Laskos

<[email protected]>
<[email protected]>

@version: 0.1.1

Defined Under Namespace

Classes: Entry

Instance Method Summary collapse

Constructor Details

#initialize(opts, settings) ⇒ Log

Returns a new instance of Log.



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/arachni/ui/web/log.rb', line 44

def initialize( opts, settings )

    @opts     = opts
    @settings = settings

    DataMapper::setup( :log, "sqlite3://#{@settings.db}/log.db" )
    DataMapper.repository( :log ) {
        DataMapper.finalize
        Entry.auto_upgrade!
    }
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/arachni/ui/web/log.rb', line 60

def method_missing( sym, *args, &block )

    owner, action = sym.to_s.split( '_', 2 )

    if args && args[1]
        object = args[1]
    end

    if env = args[0]
        addr = env['REMOTE_ADDR']
        host = env['REMOTE_HOST']
    end

    DataMapper.repository( :log ) {
        Entry.create(
            :action => action,
            :owner  => owner,
            :object => object,
            :client_addr => addr,
            :client_host => host,
            :datestamp   => Time.now.asctime
        )
    }
end

Instance Method Details

#entryObject



56
57
58
# File 'lib/arachni/ui/web/log.rb', line 56

def entry
    DataMapper.repository( :log ) { Entry }
end