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