Sha256: 5e56e5748bd4b368a2f0385546b4fed7b915338fb49aa89dba4a4f17e3afa8aa
Contents?: true
Size: 1.47 KB
Versions: 3
Compression:
Stored size: 1.47 KB
Contents
module Brakeman ASTFile = Struct.new(:path, :ast) # This class handles reading and parsing files. class FileParser attr_reader :file_list def initialize tracker, app_tree @tracker = tracker @timeout = @tracker.options[:parser_timeout] @app_tree = app_tree @file_list = {} end def parse_files list, type read_files list, type do |path, contents| if ast = parse_ruby(contents, path) ASTFile.new(path, ast) end end end def read_files list, type @file_list[type] ||= [] list.each do |path| result = yield path, read_path(path) if result @file_list[type] << result end end end def parse_ruby input, path, parser = RubyParser.new begin Brakeman.debug "Parsing #{path}" parser.parse input, path, @timeout rescue Racc::ParseError => e if parser.class == RubyParser return parse_ruby(input, path, RubyParser.latest) else @tracker.error e, "Could not parse #{path}" nil end rescue Timeout::Error => e @tracker.error Exception.new("Parsing #{path} took too long (> #{@timeout} seconds). Try increasing the limit with --parser-timeout"), caller nil rescue => e @tracker.error e.exception(e.message + "\nWhile processing #{path}"), e.backtrace nil end end def read_path path @app_tree.read_path path end end end
Version data entries
3 entries across 3 versions & 3 rubygems
Version | Path |
---|---|
brakeman-4.5.0 | lib/brakeman/file_parser.rb |
brakeman-min-4.5.0 | lib/brakeman/file_parser.rb |
brakeman-lib-4.5.0 | lib/brakeman/file_parser.rb |