Class: Arachni::Data::Issues
Overview
Stores and provides access to all logged Issues.
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Utilities
#available_port, available_port_mutex, #bytes_to_kilobytes, #bytes_to_megabytes, #caller_name, #caller_path, #cookie_decode, #cookie_encode, #cookies_from_file, #cookies_from_parser, #cookies_from_response, #exception_jail, #exclude_path?, #follow_protocol?, #form_decode, #form_encode, #forms_from_parser, #forms_from_response, #full_and_absolute_url?, #generate_token, #get_path, #hms_to_seconds, #html_decode, #html_encode, #include_path?, #links_from_parser, #links_from_response, #normalize_url, #page_from_response, #page_from_url, #parse_set_cookie, #path_in_domain?, #path_too_deep?, #port_available?, #rand_port, #random_seed, #redundant_path?, #regexp_array_match, #remove_constants, #request_parse_body, #seconds_to_hms, #skip_page?, #skip_path?, #skip_resource?, #skip_response?, #to_absolute, #uri_decode, #uri_encode, #uri_parse, #uri_parse_query, #uri_parser, #uri_rewrite
Methods included from UI::Output
#caller_location, #debug?, #debug_level, #debug_level_1?, #debug_level_2?, #debug_level_3?, #debug_level_4?, #debug_off, #debug_on, #disable_only_positives, #error_buffer, #error_log_fd, #error_logfile, #has_error_log?, #included, #log_error, #mute, #muted?, #only_positives, #only_positives?, #print_bad, #print_debug, #print_debug_backtrace, #print_debug_exception, #print_debug_level_1, #print_debug_level_2, #print_debug_level_3, #print_debug_level_4, #print_error, #print_error_backtrace, #print_exception, #print_info, #print_line, #print_ok, #print_status, #print_verbose, #reroute_to_file, #reroute_to_file?, reset_output_options, #set_error_logfile, #unmute, #verbose?, #verbose_off, #verbose_on
Constructor Details
#initialize ⇒ Issues
Returns a new instance of Issues.
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/arachni/data/issues.rb', line 34
def initialize
super
@collection = {}
@digests = Set.new
store
end
|
Instance Attribute Details
#collection ⇒ Hash{Integer=>Issue}
28
29
30
|
# File 'lib/arachni/data/issues.rb', line 28
def collection
@collection
end
|
#digests ⇒ Set<Integer>
32
33
34
|
# File 'lib/arachni/data/issues.rb', line 32
def digests
@digests
end
|
Class Method Details
.load(directory) ⇒ Object
181
182
183
184
185
186
187
188
189
190
191
192
|
# File 'lib/arachni/data/issues.rb', line 181
def self.load( directory )
issues = new
Dir["#{directory}/issue_*"].each do |issue_file|
issue = Marshal.load( IO.binread( issue_file ) )
issues.collection[issue.digest] = issue
end
issues.digests.merge Marshal.load( IO.binread( "#{directory}/digests" ) )
issues
end
|
Instance Method Details
#<<(issue) ⇒ Issues
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
# File 'lib/arachni/data/issues.rb', line 119
def <<( issue )
notify_on_new_pre_deduplication( issue )
return self if include?( issue )
digest = issue.digest
@digests << digest
synchronize do
notify_on_new( issue )
if store?
@collection[digest] = issue
end
end
self
end
|
#==(other) ⇒ Object
194
195
196
|
# File 'lib/arachni/data/issues.rb', line 194
def ==( other )
hash == other.hash
end
|
#[](digest) ⇒ Issue
141
142
143
|
# File 'lib/arachni/data/issues.rb', line 141
def []( digest )
@collection[digest]
end
|
Returns All logged issues.
95
96
97
|
# File 'lib/arachni/data/issues.rb', line 95
def all
@collection.values
end
|
#any? ⇒ Boolean
159
160
161
|
# File 'lib/arachni/data/issues.rb', line 159
def any?
@collection.any?
end
|
202
203
204
205
206
|
# File 'lib/arachni/data/issues.rb', line 202
def clear
@digests.clear
@collection.clear
clear_observers
end
|
#do_not_store ⇒ Object
Disables issue storage via #<<.
88
89
90
91
|
# File 'lib/arachni/data/issues.rb', line 88
def do_not_store
@store = false
self
end
|
#dump(directory) ⇒ Object
171
172
173
174
175
176
177
178
179
|
# File 'lib/arachni/data/issues.rb', line 171
def dump( directory )
FileUtils.mkdir_p( directory )
@collection.each do |digest, issue|
IO.binwrite( "#{directory}/issue_#{digest}", Marshal.dump( issue ) )
end
IO.binwrite( "#{directory}/digests", Marshal.dump( digests ) )
end
|
#each(&block) ⇒ Object
99
100
101
|
# File 'lib/arachni/data/issues.rb', line 99
def each( &block )
all.each( &block )
end
|
#empty? ⇒ Boolean
163
164
165
|
# File 'lib/arachni/data/issues.rb', line 163
def empty?
!any?
end
|
151
152
153
|
# File 'lib/arachni/data/issues.rb', line 151
def first
all.first
end
|
198
199
200
|
# File 'lib/arachni/data/issues.rb', line 198
def hash
@digests.hash
end
|
#include?(issue) ⇒ Bool
Returns true
if issue
is.
109
110
111
|
# File 'lib/arachni/data/issues.rb', line 109
def include?( issue )
@digests.include? issue.digest
end
|
155
156
157
|
# File 'lib/arachni/data/issues.rb', line 155
def last
all.last
end
|
#map(&block) ⇒ Object
103
104
105
|
# File 'lib/arachni/data/issues.rb', line 103
def map( &block )
all.map( &block )
end
|
#on_new_pre_deduplication(&block) ⇒ Object
23
|
# File 'lib/arachni/data/issues.rb', line 23
advertise :on_new_pre_deduplication
|
167
168
169
|
# File 'lib/arachni/data/issues.rb', line 167
def size
@collection.size
end
|
Returns Sorted array of Issues.
147
148
149
|
# File 'lib/arachni/data/issues.rb', line 147
def sort
all.sort_by(&:severity).reverse
end
|
#statistics ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/arachni/data/issues.rb', line 47
def statistics
by_severity = Hash.new(0)
each { |issue| by_severity[issue.severity.to_sym] += 1 }
by_type = Hash.new(0)
each { |issue| by_type[issue.name] += 1 }
by_check = Hash.new(0)
each { |issue| by_check[issue.check[:shortname]] += 1 }
{
total: size,
by_severity: by_severity,
by_type: by_type,
by_check: by_check
}
end
|
Enables issue storage via #<<.
79
80
81
82
|
# File 'lib/arachni/data/issues.rb', line 79
def store
@store = true
self
end
|
#store? ⇒ Bool
Returns true
if #<< is configured to store issues, false
otherwise.
71
72
73
|
# File 'lib/arachni/data/issues.rb', line 71
def store?
@store
end
|