brakeman 3.1.3 → 3.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0a5242c2a00eaa622ccfd793730c516642f1835c
4
- data.tar.gz: 9e684857baaddfc23a7c8b517797e9361fd9d0a1
3
+ metadata.gz: e2f73f15176bd0a6f4d9dfcc629f2c058b30d837
4
+ data.tar.gz: b3eb152ea1d579034ccae53d8c0ae2a5765533af
5
5
  SHA512:
6
- metadata.gz: 75051e388396af7a75b9f9773ba4f16971f1033441fc74dcc2968a0b5421e8cd4117d6f0e18b23d61c891aba78dcd02a24bb255786e559bd12f1b661be984089
7
- data.tar.gz: 403638a85e9dff267149e9204cf4789a439112cbebb35df79191f8a036d981f916dc7dfb1a22488f677cda45ffee21f29e18123136db834be2febd0d82962fb7
6
+ metadata.gz: 9b576a52670e2fe3b3ae035d6f4da88c94635da2c20bab6214fdec4301ae19b30d056a8541742e6ef4abaac801214c65a6438ca94588c44d8cf5b3546602125b
7
+ data.tar.gz: 1d807d4acc2b35e8aaa6d938a669d953347be9aace422fdd5ce2c9fb4e6b840665b916d34cc52dee2c37d25caab0b6642e1de26b6c37cead2619f14e4cc665a0
data/CHANGES CHANGED
@@ -1,3 +1,11 @@
1
+ # 3.1.4
2
+
3
+ * Emit brakeman's native fingerprints for Code Climate engine (Noah Davis)
4
+ * Ignore secrets.yml if in .gitignore
5
+ * Clean up Ruby warnings (Andy Waite)
6
+ * Increase test coverage for option parsing (Zander Mackie)
7
+ * Work around safe_yaml error
8
+
1
9
  # 3.1.3
2
10
 
3
11
  * Check for session secret in secrets.yml
@@ -12,7 +12,7 @@ begin
12
12
  rescue OptionParser::ParseError => e
13
13
  $stderr.puts e.message.capitalize
14
14
  $stderr.puts "Please see `brakeman --help` for valid options"
15
- exit -1
15
+ exit(-1)
16
16
  end
17
17
 
18
18
  #Exit early for these options
@@ -1,5 +1,4 @@
1
1
  require 'rubygems'
2
- require 'safe_yaml/load'
3
2
  require 'set'
4
3
 
5
4
  module Brakeman
@@ -93,6 +92,8 @@ module Brakeman
93
92
 
94
93
  #Load configuration file
95
94
  if config = config_file(custom_location, app_path)
95
+ require 'date' # https://github.com/dtao/safe_yaml/issues/80
96
+ require 'safe_yaml/load'
96
97
  options = SafeYAML.load_file config, :deserialize_symbols => true
97
98
 
98
99
  if options
@@ -262,15 +263,15 @@ module Brakeman
262
263
  task_path = File.join("lib", "tasks", "brakeman.rake")
263
264
  end
264
265
 
265
- if not File.exists? rake_path
266
+ if not File.exist? rake_path
266
267
  raise RakeInstallError, "No Rakefile detected"
267
- elsif File.exists? task_path
268
+ elsif File.exist? task_path
268
269
  raise RakeInstallError, "Task already exists"
269
270
  end
270
271
 
271
272
  require 'fileutils'
272
273
 
273
- if not File.exists? "lib/tasks"
274
+ if not File.exist? "lib/tasks"
274
275
  notify "Creating lib/tasks"
275
276
  FileUtils.mkdir_p "lib/tasks"
276
277
  end
@@ -279,7 +280,7 @@ module Brakeman
279
280
 
280
281
  FileUtils.cp "#{path}/brakeman/brakeman.rake", task_path
281
282
 
282
- if File.exists? task_path
283
+ if File.exist? task_path
283
284
  notify "Task created in #{task_path}"
284
285
  notify "Usage: rake brakeman:run[output_file]"
285
286
  else
@@ -289,6 +290,7 @@ module Brakeman
289
290
 
290
291
  #Output configuration to YAML
291
292
  def self.dump_config options
293
+ require 'yaml'
292
294
  if options[:create_config].is_a? String
293
295
  file = options[:create_config]
294
296
  else
@@ -407,7 +409,7 @@ module Brakeman
407
409
  def self.compare options
408
410
  require 'multi_json'
409
411
  require 'brakeman/differ'
410
- raise ArgumentError.new("Comparison file doesn't exist") unless File.exists? options[:previous_results_json]
412
+ raise ArgumentError.new("Comparison file doesn't exist") unless File.exist? options[:previous_results_json]
411
413
 
412
414
  begin
413
415
  previous_results = MultiJson.load(File.read(options[:previous_results_json]), :symbolize_keys => true)[:warnings]
@@ -431,7 +433,7 @@ module Brakeman
431
433
  rescue LoadError => e
432
434
  $stderr.puts e.message
433
435
  $stderr.puts "Please install the appropriate dependency: #{name}."
434
- exit! -1
436
+ exit!(-1)
435
437
  end
436
438
  end
437
439
 
@@ -43,12 +43,12 @@ module Brakeman
43
43
  end
44
44
 
45
45
  def exists?(path)
46
- File.exists?(File.join(@root, path))
46
+ File.exist?(File.join(@root, path))
47
47
  end
48
48
 
49
49
  # This is a pair for #read_path. Again, would like to kill these
50
50
  def path_exists?(path)
51
- File.exists?(path)
51
+ File.exist?(path)
52
52
  end
53
53
 
54
54
  def initializer_paths
@@ -348,7 +348,7 @@ class Brakeman::BaseCheck < Brakeman::SexpProcessor
348
348
  if @safe_input_attributes.include? method
349
349
  false
350
350
  elsif call? target and not method.to_s[-1,1] == "?"
351
- if res = has_immediate_model?(target, out)
351
+ if has_immediate_model?(target, out)
352
352
  exp
353
353
  else
354
354
  false
@@ -105,12 +105,6 @@ class Brakeman::CheckCrossSiteScripting < Brakeman::BaseCheck
105
105
  warning_code = :xss_to_json
106
106
  end
107
107
 
108
- code = if match == out
109
- nil
110
- else
111
- match
112
- end
113
-
114
108
  warn :template => @current_template,
115
109
  :warning_type => "Cross Site Scripting",
116
110
  :warning_code => warning_code,
@@ -314,7 +308,7 @@ class Brakeman::CheckCrossSiteScripting < Brakeman::BaseCheck
314
308
  initializers = tracker.check_initializers :ActiveSupport, :escape_html_entities_in_json=
315
309
  initializers.each {|result| json_escape_on = true?(result.call.first_arg) }
316
310
 
317
- if tracker.config.escape_html_entities_in_json?
311
+ if tracker.config.escape_html_entities_in_json?
318
312
  json_escape_on = true
319
313
  elsif version_between? "4.0.0", "5.0.0"
320
314
  json_escape_on = true
@@ -25,12 +25,12 @@ class Brakeman::CheckDetailedExceptions < Brakeman::BaseCheck
25
25
 
26
26
  def check_detailed_exceptions
27
27
  tracker.controllers.each do |name, controller|
28
- controller.methods_public.each do |name, definition|
28
+ controller.methods_public.each do |method_name, definition|
29
29
  src = definition[:src]
30
30
  body = src.body.last
31
31
  next unless body
32
32
 
33
- if name == :show_detailed_exceptions? and not safe? body
33
+ if method_name == :show_detailed_exceptions? and not safe? body
34
34
  if true? body
35
35
  confidence = CONFIDENCE[:high]
36
36
  else
@@ -9,6 +9,11 @@ class Brakeman::CheckMassAssignment < Brakeman::BaseCheck
9
9
 
10
10
  @description = "Finds instances of mass assignment"
11
11
 
12
+ def initialize(*)
13
+ super
14
+ @mass_assign_calls = nil
15
+ end
16
+
12
17
  def run_check
13
18
  check_mass_assignment
14
19
  check_permit!
@@ -5,6 +5,11 @@ class Brakeman::CheckNumberToCurrency < Brakeman::BaseCheck
5
5
 
6
6
  @description = "Checks for number helpers XSS vulnerabilities in certain versions"
7
7
 
8
+ def initialize(*)
9
+ super
10
+ @found_any = false
11
+ end
12
+
8
13
  def run_check
9
14
  if version_between? "2.0.0", "2.3.18" or
10
15
  version_between? "3.0.0", "3.2.16" or
@@ -35,7 +40,7 @@ class Brakeman::CheckNumberToCurrency < Brakeman::BaseCheck
35
40
  end
36
41
 
37
42
  def check_number_helper_usage
38
- number_methods = [:number_to_currency, :number_to_percentage, :number_to_human]
43
+ number_methods = [:number_to_currency, :number_to_percentage, :number_to_human]
39
44
  tracker.find_call(:target => false, :methods => number_methods).each do |result|
40
45
  arg = result[:call].second_arg
41
46
  next unless arg
@@ -22,7 +22,7 @@ class Brakeman::CheckSend < Brakeman::BaseCheck
22
22
 
23
23
  send_call = get_send result[:call]
24
24
  process_call_args send_call
25
- target = process send_call.target
25
+ process send_call.target
26
26
 
27
27
  if input = has_immediate_user_input?(send_call.first_arg)
28
28
  warn :result => result,
@@ -111,8 +111,9 @@ class Brakeman::CheckSessionSettings < Brakeman::BaseCheck
111
111
  def check_secrets_yaml
112
112
  secrets_file = "config/secrets.yml"
113
113
 
114
- if @app_tree.exists? secrets_file
114
+ if @app_tree.exists? secrets_file and not ignored? "secrets.yml" and not ignored? "config/*.yml"
115
115
  yaml = @app_tree.read secrets_file
116
+ require 'date' # https://github.com/dtao/safe_yaml/issues/80
116
117
  require 'safe_yaml/load'
117
118
  secrets = SafeYAML.load yaml
118
119
 
@@ -27,6 +27,7 @@ class Brakeman::AliasProcessor < Brakeman::SexpProcessor
27
27
  @helper_method_cache = {}
28
28
  @helper_method_info = Hash.new({})
29
29
  @or_depth_limit = (tracker && tracker.options[:branch_limit]) || 5 #arbitrary default
30
+ @meth_env = nil
30
31
  set_env_defaults
31
32
  end
32
33
 
@@ -63,7 +64,7 @@ class Brakeman::AliasProcessor < Brakeman::SexpProcessor
63
64
  end
64
65
 
65
66
  result = replace(exp)
66
-
67
+
67
68
  @exp_context.pop
68
69
 
69
70
  result
@@ -60,11 +60,11 @@ module Brakeman
60
60
  end
61
61
 
62
62
  def each &block
63
- @path.each &block
63
+ @path.each(&block)
64
64
  end
65
65
 
66
66
  def join *args
67
- self.to_a.join *args
67
+ self.to_a.join(*args)
68
68
  end
69
69
 
70
70
  def length
@@ -119,7 +119,7 @@ module Brakeman
119
119
  @already_ignored.each do |w|
120
120
  fingerprint = w[:fingerprint]
121
121
 
122
- unless @ignored_warnings.find { |w| w.fingerprint == fingerprint }
122
+ unless @ignored_warnings.find { |ignored_warning| ignored_warning.fingerprint == fingerprint }
123
123
  warnings << w
124
124
  end
125
125
  end
@@ -142,17 +142,17 @@ class Brakeman::Report::Base
142
142
  w = warning.to_row type
143
143
 
144
144
  case type
145
- when :warning
146
- convert_warning w, warning
147
- when :template
148
- convert_template_warning w, warning
149
- when :model
150
- convert_model_warning w, warning
151
- when :controller
152
- convert_controller_warning w, warning
153
- when :ignored
154
- convert_ignored_warning w, warning
155
- end
145
+ when :warning
146
+ convert_warning w, warning
147
+ when :template
148
+ convert_template_warning w, warning
149
+ when :model
150
+ convert_model_warning w, warning
151
+ when :controller
152
+ convert_controller_warning w, warning
153
+ when :ignored
154
+ convert_ignored_warning w, warning
155
+ end
156
156
  end
157
157
  end
158
158
 
@@ -19,6 +19,7 @@ class Brakeman::Report::CodeClimate < Brakeman::Report::Base
19
19
  type: "Issue",
20
20
  check_name: warning_code_name,
21
21
  description: warning.message,
22
+ fingerprint: warning.fingerprint,
22
23
  categories: ["Security"],
23
24
  severity: severity_level_for(warning.confidence),
24
25
  remediation_points: remediation_points_for(warning_code_name),
@@ -329,7 +329,7 @@ class Brakeman::Rescanner < Brakeman::Scanner
329
329
  :initializer
330
330
  when /config\/routes\.rb/
331
331
  :routes
332
- when /\/config\/.+\.rb/
332
+ when /\/config\/.+\.(rb|yml)/
333
333
  :config
334
334
  when /Gemfile|gems\./
335
335
  :gemfile
@@ -11,7 +11,7 @@ begin
11
11
  rescue LoadError => e
12
12
  $stderr.puts e.message
13
13
  $stderr.puts "Please install the appropriate dependency."
14
- exit -1
14
+ exit(-1)
15
15
  end
16
16
 
17
17
  #Scans the Rails application.
@@ -13,6 +13,8 @@ module Brakeman
13
13
  @rails = {}
14
14
  @gems = {}
15
15
  @settings = {}
16
+ @escape_html = nil
17
+ @erubis = nil
16
18
  end
17
19
 
18
20
  def allow_forgery_protection?
@@ -1,3 +1,3 @@
1
1
  module Brakeman
2
- Version = "3.1.3"
2
+ Version = "3.1.4"
3
3
  end
@@ -2,7 +2,6 @@
2
2
  #and some changes for caching hash value and tracking 'original' line number
3
3
  #of a Sexp.
4
4
  class Sexp
5
- attr_reader :paren
6
5
  attr_accessor :original_line, :or_depth
7
6
  ASSIGNMENT_BOOL = [:gasgn, :iasgn, :lasgn, :cvdecl, :cvasgn, :cdecl, :or, :and, :colon2]
8
7
 
@@ -412,13 +411,13 @@ class Sexp
412
411
  # s(:lasgn, :x, s(:lit, 1))
413
412
  # ^--lhs
414
413
  def lhs
415
- expect *ASSIGNMENT_BOOL
414
+ expect(*ASSIGNMENT_BOOL)
416
415
  self[1]
417
416
  end
418
417
 
419
418
  #Sets the left hand side of assignment or boolean.
420
419
  def lhs= exp
421
- expect *ASSIGNMENT_BOOL
420
+ expect(*ASSIGNMENT_BOOL)
422
421
  @my_hash_value = nil
423
422
  self[1] = exp
424
423
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brakeman
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.3
4
+ version: 3.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Collins
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain:
11
11
  - brakeman-public_cert.pem
12
- date: 2015-12-03 00:00:00.000000000 Z
12
+ date: 2015-12-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: test-unit