Class: Arachni::AuditStore

Inherits:
Object show all
Defined in:
lib/arachni/audit_store.rb

Overview

Arachni::AuditStore class

Represents a finished audit session.<br/> It holds information about the runtime environment, the results of the audit etc…

@author: Tasos “Zapotek” Laskos

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

@version: 0.1.2

Constant Summary collapse

MODULE_NAMESPACE =
::Arachni::Modules
ORDER =
[
    ::Arachni::Issue::Severity::HIGH,
    ::Arachni::Issue::Severity::MEDIUM,
    ::Arachni::Issue::Severity::LOW,
    ::Arachni::Issue::Severity::INFORMATIONAL
]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(audit = {}) ⇒ AuditStore

Returns a new instance of AuditStore.



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/arachni/audit_store.rb', line 84

def initialize( audit = {} )
    @plugins = {}
    @sitemap = []

    # set instance variables from audit opts
    audit.each {
        |k, v|
        self.instance_variable_set( '@' + k.to_s, v )
    }

    @options         = prepare_options( @options )
    @issues          = sort( prepare_variations( @issues ) )
    if @options['start_datetime']
        @start_datetime  = @options['start_datetime'].asctime
    else
        @start_datetime = Time.now.asctime
    end

    if @options['finish_datetime']
        @finish_datetime = @options['finish_datetime'].asctime
    else
        @finish_datetime = Time.now.asctime
    end

    @delta_time = secs_to_hms( @options['delta_time'] )
end

Instance Attribute Details

#delta_timeString (readonly)

Returns how long the audit took.

Returns:

  • (String)

    how long the audit took



73
74
75
# File 'lib/arachni/audit_store.rb', line 73

def delta_time
  @delta_time
end

#finish_datetimeString (readonly)

Returns the date and time when the audit finished.

Returns:

  • (String)

    the date and time when the audit finished



68
69
70
# File 'lib/arachni/audit_store.rb', line 68

def finish_datetime
  @finish_datetime
end

#issuesArray<Issue> (readonly)

Returns the discovered issues.

Returns:



53
54
55
# File 'lib/arachni/audit_store.rb', line 53

def issues
  @issues
end

#optionsHash (readonly)

Returns the runtime arguments/options of the environment.

Returns:

  • (Hash)

    the runtime arguments/options of the environment



43
44
45
# File 'lib/arachni/audit_store.rb', line 43

def options
  @options
end

#pluginsHash (readonly)

Returns plugin results.

Returns:

  • (Hash)

    plugin results



58
59
60
# File 'lib/arachni/audit_store.rb', line 58

def plugins
  @plugins
end

#revisionString (readonly)

Returns the revision of the framework class.

Returns:

  • (String)

    the revision of the framework class



38
39
40
# File 'lib/arachni/audit_store.rb', line 38

def revision
  @revision
end

#sitemapArray (readonly)

Returns all the urls crawled.

Returns:

  • (Array)

    all the urls crawled



48
49
50
# File 'lib/arachni/audit_store.rb', line 48

def sitemap
  @sitemap
end

#start_datetimeString (readonly)

Returns the date and time when the audit started.

Returns:

  • (String)

    the date and time when the audit started



63
64
65
# File 'lib/arachni/audit_store.rb', line 63

def start_datetime
  @start_datetime
end

#versionString (readonly)

Returns the version of the framework.

Returns:

  • (String)

    the version of the framework



33
34
35
# File 'lib/arachni/audit_store.rb', line 33

def version
  @version
end

Class Method Details

.load(file) ⇒ AuditStore

Loads and returns an AuditStore object from file

Parameters:

  • file (String)

    the file to load

Returns:



118
119
120
121
122
123
124
125
126
# File 'lib/arachni/audit_store.rb', line 118

def AuditStore.load( file )
     begin
         r = YAML.load( IO.read( file ) )
         r.version
         r
     rescue Exception => e
         Marshal.load( File.binread( file ) )
     end
end

Instance Method Details

#save(file) ⇒ Object

Saves ‘self’ to file

Parameters:



133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/arachni/audit_store.rb', line 133

def save( file )
    begin
        File.open( file, 'w' ) {
            |f|
            f.write( YAML.dump( self ) )
        }
    rescue
        File.open( file, 'wb' ) {
            |f|
            f.write( Marshal.dump( self ) )
        }
    end
end

#to_hHash

Returns ‘self’ and all objects in its instance vars as hashes

Returns:

  • (Hash)


152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/arachni/audit_store.rb', line 152

def to_h
    hash = obj_to_hash( self ).dup

    hash['issues'] = hash['issues'].map {
        |issue|
        issue.variations = issue.variations.map { |var| obj_to_hash( var ) }
        obj_to_hash( issue )
    }

    hash['plugins'].each {
        |plugin, results|
        next if !results[:options]

        hash['plugins'][plugin][:options] = hash['plugins'][plugin][:options].map {
            |opt|
            opt.to_h
        }
    }

    return hash
end