Class: Arachni::AuditStore

Inherits:
Object show all
Defined in:
lib/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.1

Constant Summary collapse

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 = {}, framework) ⇒ AuditStore

Returns a new instance of AuditStore.



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/audit_store.rb', line 82

def initialize( audit = {}, framework )

    @framework = framework

    # 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 ) )
    @start_datetime  = @options['start_datetime'].asctime

    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



70
71
72
# File 'lib/audit_store.rb', line 70

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



65
66
67
# File 'lib/audit_store.rb', line 65

def finish_datetime
  @finish_datetime
end

#frameworkObject

Returns the value of attribute framework.



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

def framework
  @framework
end

#issuesArray<Issue> (readonly)

Returns the discovered issues.

Returns:

  • (Array<Issue>)

    the discovered issues



53
54
55
# File 'lib/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/audit_store.rb', line 43

def options
  @options
end

#pluginsObject (readonly)

Returns the value of attribute plugins.



55
56
57
# File 'lib/audit_store.rb', line 55

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/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/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



60
61
62
# File 'lib/audit_store.rb', line 60

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/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:



113
114
115
116
117
118
119
# File 'lib/audit_store.rb', line 113

def AuditStore.load( file )
     begin
        Marshal.load( IO.read( file ) )
     rescue
         YAML.load( IO.read( file ) )
     end
end

Instance Method Details

#save(file) ⇒ Object

Saves ‘self’ to file

Parameters:



126
127
128
129
130
131
132
133
134
# File 'lib/audit_store.rb', line 126

def save( file )
    @framework = ''
    f = File.open( file, 'w' )
    begin
        Marshal.dump( self, f )
    rescue
        YAML.dump( self, f )
    end
end

#to_hHash

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

Returns:

  • (Hash)


141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/audit_store.rb', line 141

def to_h

    hash = obj_to_hash( self )

    issues = []
    hash['issues'].each {
        |issue|
        issues << obj_to_hash( issue )
    }

    hash['issues'] = issues
    return hash
end