Sha256: 62fd9962f5cb143002bc91a42cf444cc791a8b397bd3748cc7fb42bcae09f5d5
Contents?: true
Size: 1.44 KB
Versions: 3
Compression:
Stored size: 1.44 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 @tracker = tracker @timeout = @tracker.options[:parser_timeout] @app_tree = @tracker.app_tree @file_list = {} end def parse_files list, type read_files list, type do |path, contents| if ast = parse_ruby(contents, path.relative) ASTFile.new(path, ast) end end end def read_files list, type @file_list[type] ||= [] list.each do |path| file = @app_tree.file_path(path) result = yield file, file.read if result @file_list[type] << result end end end # _path_ can be a string or a Brakeman::FilePath def parse_ruby input, path if path.is_a? Brakeman::FilePath path = path.relative end begin Brakeman.debug "Parsing #{path}" RubyParser.new.parse input, path, @timeout rescue Racc::ParseError => e @tracker.error e, "Could not parse #{path}" nil 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 end end
Version data entries
3 entries across 3 versions & 3 rubygems
Version | Path |
---|---|
brakeman-4.10.1 | lib/brakeman/file_parser.rb |
brakeman-lib-4.10.1 | lib/brakeman/file_parser.rb |
brakeman-min-4.10.1 | lib/brakeman/file_parser.rb |