brakeman-lib 7.1.0 → 7.1.1

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
  SHA256:
3
- metadata.gz: c2279f2b84d3be0e168b6b16e59855f5507c0514df39c4fb4b63d76721b7e87d
4
- data.tar.gz: 37751126761102664819b8779940ecbc2097caec46176f4fc8d3b0f740585579
3
+ metadata.gz: 132a7205f3014d6b941fcfd4785bd98778bd15f07e8a9f1c47a417a848d315e8
4
+ data.tar.gz: '0896504a08989f485b40e35f79f477540dd4aeab24b66212408ae073901fcdca'
5
5
  SHA512:
6
- metadata.gz: 2c8a2bf6f2f3c2ee11419def7e7e91a4942cf337504db7a6e54c66f7b6a645cef31ac86de9580f78bdfe0ca66d08387d4125d36f106ac63354423e3973917deb
7
- data.tar.gz: b77e61957f321cdbdf33a41b057779c5b5f60a41512d538737a8aa0e57e6c6fc13cf9213cc710995ff55de04a57c1640492108529fda616553c6fb7ba5cd81d7
6
+ metadata.gz: 8c726e8ef155015305d551223b5f9d222b686ecd463ced6f37b0a9b0281624c9215ae93f17b9f28b1f5c55b246e5a7d59d4ad9429d17dccb64ae8c299cbc1902
7
+ data.tar.gz: c4aaa6f70c52bbc6bb4c5428b7b3f28569946d51efba7166eda4bea55d8d5aabb472141bd560b640e3491a2bd073acf5674556ee4c3d8124cb0c7e4f24883c89
data/CHANGES.md CHANGED
@@ -1,3 +1,16 @@
1
+ # 7.1.1 - 2025-11-03
2
+
3
+ * Fix false positive when calling `with_content` on ViewComponents (Peer Allan)
4
+ * Word wrap text output in pager
5
+ * Consider Tempfile.create.path as safe input (Ali Ismayilov)
6
+ * Exclude directories before searching for files
7
+ * Check each side of `or` SQL arguments
8
+ * Ignore attribute builder in Haml 6
9
+ * Add `FilePath#to_path` for Ruby 3.5 compatibility (S-H-GAMELINKS)
10
+ * Fix SQL injection check for calculate method (Rohan Sharma)
11
+ * Fix missing `td` in HTML report (John Hawthorn)
12
+ * Check for unsafe SQL when two arguments are passed to AR methods (Patrick Brinich-Langlois)
13
+
1
14
  # 7.1.0 - 2025-07-18
2
15
 
3
16
  * Add EOL dates for Rails 8.0 and Ruby 3.4
@@ -7,7 +20,7 @@
7
20
  * Improve ignored warnings layout in HTML report (Sebastien Savater)
8
21
  * Update JUnit report for CircleCI (Philippe Bernery)
9
22
  * Only load escape functionality from cgi library (Earlopain)
10
- * Add `--ensure-no-obsolete-config-entries` option (viralpraxis)
23
+ * Add `--ensure-no-obsolete-ignore-entries` option (viralpraxis)
11
24
 
12
25
  # 7.0.2 - 2025-04-04
13
26
 
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  [![Brakeman Logo](http://brakemanscanner.org/images/logo_medium.png)](http://brakemanscanner.org/)
2
2
 
3
3
  [![Build Status](https://circleci.com/gh/presidentbeef/brakeman.svg?style=svg)](https://circleci.com/gh/presidentbeef/brakeman)
4
- [![Test Coverage](https://api.codeclimate.com/v1/badges/1b08a5c74695cb0d11ec/test_coverage)](https://codeclimate.com/github/presidentbeef/brakeman/test_coverage)
4
+ [![Code Coverage](https://qlty.sh/gh/presidentbeef/projects/brakeman/coverage.svg)](https://qlty.sh/gh/presidentbeef/projects/brakeman)
5
5
 
6
6
  # Brakeman
7
7
 
@@ -33,6 +33,7 @@ module Brakeman
33
33
  # * "path1/" - Matches any path that contains "path1" in the project directory.
34
34
  # * "/path1/ - Matches any path that is rooted at "path1" in the project directory.
35
35
  #
36
+ # TODO: This is wacky and I don't like it.
36
37
  def self.regex_for_paths(paths)
37
38
  path_regexes = paths.map do |f|
38
39
  # If path ends in a file separator then we assume it is a path rather
@@ -192,7 +193,12 @@ module Brakeman
192
193
  files = patterns.flat_map { |pattern| Dir.glob(pattern) }
193
194
  files.uniq.lazy
194
195
  else
195
- pattern = "#{root_search_pattern}#{directory}/**/#{name}#{extensions}"
196
+ if directory == '.'
197
+ pattern = File.join(top_directories_pattern, '**', "#{name}#{extensions}")
198
+ else
199
+ pattern = "#{root_search_pattern}#{directory}/**/#{name}#{extensions}"
200
+ end
201
+
196
202
  Dir.glob(pattern).lazy
197
203
  end
198
204
  end
@@ -257,18 +263,47 @@ module Brakeman
257
263
  end
258
264
 
259
265
  def match_path files, path
266
+ # TODO: Converting to Pathnames and Strings seems like a lot
267
+ # of converting that could perhaps all be handled in Brakeman::FilePath
268
+ # instead?
260
269
  absolute_path = Pathname.new(path)
270
+
261
271
  # relative root never has a leading separator. But, we use a leading
262
272
  # separator in a @skip_files entry to imply that a directory is
263
273
  # "absolute" with respect to the project directory.
264
- project_relative_path = File.join(
265
- File::SEPARATOR,
266
- absolute_path.relative_path_from(@project_root_path).to_s
267
- )
274
+ #
275
+ # Also directories need a trailing separator.
276
+ project_relative_path = if File.directory?(path)
277
+ File.join(
278
+ File::SEPARATOR,
279
+ absolute_path.relative_path_from(@project_root_path).to_s,
280
+ File::SEPARATOR
281
+ )
282
+ else
283
+ File.join(
284
+ File::SEPARATOR,
285
+ absolute_path.relative_path_from(@project_root_path).to_s
286
+ )
287
+ end
268
288
 
269
289
  files.match(project_relative_path)
270
290
  end
271
291
 
292
+ def top_directories_pattern
293
+ top_dirs = convert_to_file_paths(Dir.glob(File.join(root_search_pattern, '*/')))
294
+ top_dirs.reject! { |d| File.symlink?(d) or !File.directory?(d) }
295
+ top_dirs = reject_global_excludes(top_dirs)
296
+ top_dirs = reject_skipped_files(top_dirs)
297
+
298
+ if top_dirs.empty?
299
+ # Fall back to searching everything, otherwise the empty pattern
300
+ # will start searching from the global root
301
+ root_search_pattern
302
+ else
303
+ "{#{top_dirs.join(',')}}"
304
+ end
305
+ end
306
+
272
307
  def root_search_pattern
273
308
  return @root_search_pattern if @root_search_pattern
274
309
  @root_search_pattern = search_pattern(@root)
@@ -151,10 +151,13 @@ class Brakeman::BaseCheck < Brakeman::SexpProcessor
151
151
  method[-1] == "?"
152
152
  end
153
153
 
154
- TEMP_FILE_PATH = s(:call, s(:call, s(:const, :Tempfile), :new), :path).freeze
154
+ TEMP_FILE_PATH = [
155
+ s(:call, s(:call, s(:const, :Tempfile), :new), :path).freeze,
156
+ s(:call, s(:call, s(:const, :Tempfile), :create), :path).freeze
157
+ ].freeze
155
158
 
156
159
  def temp_file_path? exp
157
- exp == TEMP_FILE_PATH
160
+ TEMP_FILE_PATH.include? exp
158
161
  end
159
162
 
160
163
  #Report a warning
@@ -101,6 +101,11 @@ class Brakeman::CheckRender < Brakeman::BaseCheck
101
101
  def renderable? exp
102
102
  return false unless call?(exp) and constant?(exp.target)
103
103
 
104
+ if exp.method == :with_content
105
+ exp = exp.target
106
+ end
107
+
108
+ return false unless constant?(exp.target)
104
109
  target_class_name = class_name(exp.target)
105
110
  known_renderable_class?(target_class_name) or tracker.find_method(:render_in, target_class_name)
106
111
  end
@@ -188,11 +188,15 @@ class Brakeman::CheckSQL < Brakeman::BaseCheck
188
188
  when :find_by_sql, :count_by_sql
189
189
  check_by_sql_arguments call.first_arg
190
190
  when :calculate
191
- check_find_arguments call.third_arg
191
+ if call.arglist.length > 2
192
+ unsafe_sql?(call.second_arg) or check_find_arguments(call.third_arg)
193
+ elsif call.arglist.length > 1
194
+ unsafe_sql?(call.second_arg)
195
+ end
192
196
  when :last, :first, :all
193
197
  check_find_arguments call.first_arg
194
198
  when :average, :count, :maximum, :minimum, :sum
195
- if call.length > 5
199
+ if call.arglist.length > 1
196
200
  unsafe_sql?(call.first_arg) or check_find_arguments(call.last_arg)
197
201
  else
198
202
  check_find_arguments call.last_arg
@@ -315,6 +319,9 @@ class Brakeman::CheckSQL < Brakeman::BaseCheck
315
319
  check_hash_keys arg
316
320
  elsif node_type? arg, :lit, :str
317
321
  nil
322
+ elsif node_type? arg, :or
323
+ check_query_arguments(arg.lhs) or
324
+ check_query_arguments(arg.rhs)
318
325
  else
319
326
  #Hashes are safe...but we check above for hash, so...?
320
327
  unsafe_sql? arg, :ignore_hash
@@ -68,6 +68,10 @@ module Brakeman
68
68
  self.absolute
69
69
  end
70
70
 
71
+ # Required for Pathname compatibility.
72
+ # Ruby 3.5+ requires Pathname#initialize to receive a String or an object with to_path method.
73
+ alias to_path to_str
74
+
71
75
  # Returns a string with the absolute path.
72
76
  def to_s
73
77
  self.to_str
@@ -436,6 +436,12 @@ class Brakeman::AliasProcessor < Brakeman::SexpProcessor
436
436
  exp.method == :open
437
437
  end
438
438
 
439
+ def temp_file_create? exp
440
+ call? exp and
441
+ exp.target == TEMP_FILE_CLASS and
442
+ exp.method == :create
443
+ end
444
+
439
445
  def temp_file_new line
440
446
  s(:call, TEMP_FILE_CLASS, :new).line(line)
441
447
  end
@@ -465,6 +471,9 @@ class Brakeman::AliasProcessor < Brakeman::SexpProcessor
465
471
  elsif temp_file_open? call
466
472
  local = Sexp.new(:lvar, block_args.last)
467
473
  env.current[local] = temp_file_new(exp.line)
474
+ elsif temp_file_create? call
475
+ local = Sexp.new(:lvar, block_args.last)
476
+ env.current[local] = temp_file_new(exp.line)
468
477
  else
469
478
  block_args.each do |e|
470
479
  #Force block arg(s) to be local
@@ -166,7 +166,7 @@ class Brakeman::HamlTemplateProcessor < Brakeman::TemplateProcessor
166
166
  def haml_attribute_builder? exp
167
167
  call? exp and
168
168
  exp.target == ATTRIBUTE_BUILDER and
169
- exp.method == :build
169
+ (exp.method == :build or exp.method == :build_id)
170
170
  end
171
171
 
172
172
  def fix_textareas? exp
@@ -92,7 +92,7 @@ module Brakeman
92
92
  if system("which less > /dev/null")
93
93
  less_help = `less -?`
94
94
 
95
- ["-R ", "-F ", "-X "].each do |opt|
95
+ ["-R ", "-F ", "-X ", " --wordwrap"].each do |opt|
96
96
  if less_help.include? opt
97
97
  @less_options << opt
98
98
  end
@@ -51,7 +51,7 @@
51
51
  <tr>
52
52
  <td><%= tracker.app_path %></td>
53
53
  <td><%= rails_version %></td>
54
- <td><%= brakeman_version %>
54
+ <td><%= brakeman_version %></td>
55
55
  <td>
56
56
  <%= tracker.start_time %><br><br>
57
57
  <%= tracker.duration %> seconds
@@ -1,3 +1,3 @@
1
1
  module Brakeman
2
- Version = "7.1.0"
2
+ Version = "7.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brakeman-lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.1.0
4
+ version: 7.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Collins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-07-18 00:00:00.000000000 Z
11
+ date: 2025-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -470,7 +470,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
470
470
  - !ruby/object:Gem::Version
471
471
  version: '0'
472
472
  requirements: []
473
- rubygems_version: 3.4.1
473
+ rubygems_version: 3.3.27
474
474
  signing_key:
475
475
  specification_version: 4
476
476
  summary: Security vulnerability scanner for Ruby on Rails.