Class: Brakeman::GemProcessor
- Inherits:
-
BasicProcessor
- Object
- SexpProcessor
- BasicProcessor
- Brakeman::GemProcessor
- Defined in:
- lib/brakeman/processors/gem_processor.rb
Overview
Processes Gemfile and Gemfile.lock
Constant Summary
Constants included from Util
Util::ALL_COOKIES, Util::ALL_PARAMETERS, Util::COOKIES, Util::COOKIES_SEXP, Util::PARAMETERS, Util::PARAMS_SEXP, Util::PATH_PARAMETERS, Util::QUERY_PARAMETERS, Util::REQUEST_COOKIES, Util::REQUEST_ENV, Util::REQUEST_PARAMETERS, Util::REQUEST_PARAMS, Util::SESSION, Util::SESSION_SEXP
Constants inherited from SexpProcessor
Instance Attribute Summary
Attributes inherited from SexpProcessor
Instance Method Summary collapse
-
#initialize(*args) ⇒ GemProcessor
constructor
A new instance of GemProcessor.
- #process_call(exp) ⇒ Object
- #process_gem_lock ⇒ Object
- #process_gems(gem_files) ⇒ Object
-
#set_gem_version_and_file(line, file, line_num) ⇒ Object
Supports .rc2 but not ~>, >=, or <=.
Methods inherited from BasicProcessor
Methods included from Util
#array?, #block?, #call?, #camelize, #class_name, #constant?, #contains_class?, #context_for, #cookies?, #false?, #file_by_name, #file_for, #github_url, #hash?, #hash_access, #hash_insert, #hash_iterate, #integer?, #make_call, #node_type?, #number?, #params?, #pluralize, #rails_version, #regexp?, #relative_path, #request_env?, #request_value?, #result?, #set_env_defaults, #sexp?, #string?, #string_interp?, #symbol?, #table_to_csv, #template_path_to_name, #true?, #truncate_table, #underscore
Methods included from ProcessorHelper
#current_file_name, #process_all, #process_all!, #process_call_args, #process_call_defn?, #process_class, #process_module
Methods inherited from SexpProcessor
#in_context, #process, processors, #scope
Constructor Details
#initialize(*args) ⇒ GemProcessor
Returns a new instance of GemProcessor.
6 7 8 9 |
# File 'lib/brakeman/processors/gem_processor.rb', line 6 def initialize *args super @gem_name_version = /^\s*([-_+.A-Za-z0-9]+) \((\w(\.\w+)*)\)/ end |
Instance Method Details
#process_call(exp) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/brakeman/processors/gem_processor.rb', line 23 def process_call exp if exp.target == nil if exp.method == :gem gem_name = exp.first_arg return exp unless string? gem_name gem_version = exp.second_arg version = if string? gem_version gem_version.value else nil end @tracker.config.add_gem gem_name.value, version, @gemfile, exp.line elsif exp.method == :ruby version = exp.first_arg if string? version @tracker.config.set_ruby_version version.value end end end exp end |
#process_gem_lock ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/brakeman/processors/gem_processor.rb', line 49 def process_gem_lock line_num = 1 file = @gem_files[:gemlock][:file] @gem_files[:gemlock][:src].each_line do |line| set_gem_version_and_file line, file, line_num line_num += 1 end end |
#process_gems(gem_files) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/brakeman/processors/gem_processor.rb', line 11 def process_gems gem_files @gem_files = gem_files @gemfile = gem_files[:gemfile][:file] process gem_files[:gemfile][:src] if gem_files[:gemlock] process_gem_lock end @tracker.config.set_rails_version end |
#set_gem_version_and_file(line, file, line_num) ⇒ Object
Supports .rc2 but not ~>, >=, or <=
59 60 61 62 63 |
# File 'lib/brakeman/processors/gem_processor.rb', line 59 def set_gem_version_and_file line, file, line_num if line =~ @gem_name_version @tracker.config.add_gem $1, $2, file, line_num end end |