Module: Arachni::Module::Utilities
- Extended by:
- Utilities
- Includes:
- Utilities
- Included in:
- Manager, Utilities, Plugin::Base, Report::Base
- Defined in:
- lib/arachni/module/utilities.rb
Overview
Includes some useful methods for the system, the modules etc…
Instance Method Summary collapse
Methods included from Utilities
#available_port, #cookie_encode, #cookies_from_document, #cookies_from_file, #cookies_from_response, #exception_jail, #exclude_path?, #extract_domain, #follow_protocol?, #form_decode, #form_encode, #form_parse_request_body, #forms_from_document, #forms_from_response, #generate_token, #get_path, #html_decode, #html_encode, #include_path?, #links_from_document, #links_from_response, #normalize_url, #page_from_response, #page_from_url, #parse_query, #parse_set_cookie, #parse_url_vars, #path_in_domain?, #path_too_deep?, #port_available?, #rand_port, #redundant_path?, #remove_constants, #seed, #skip_page?, #skip_path?, #skip_resource?, #to_absolute, #uri_decode, #uri_encode, #uri_parse, #uri_parser, #url_sanitize
Instance Method Details
#read_file(filename, &block) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/arachni/module/utilities.rb', line 38 def read_file( filename, &block ) mod_path = block_given? ? block.source_location.first : caller.first.split(':').first # the name of the module that called us mod_name = File.basename( mod_path, ".rb" ) # the path to the module's data file directory path = File.( File.dirname( mod_path ) ) + '/' + mod_name + '/' file = File.open( path + '/' + filename ) if block_given? # I really hope that ruby frees each line as soon as possible # otherwise this provides no advantage file.each { |line| yield line.strip } else file.read.lines.map { |l| l.strip } end ensure file.close end |