brakeman-lib 8.0.4 → 8.0.5

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: d07db98e56b03b45fd3347a5982628ab3421d8bba0c1a1d55a3b685432ef8375
4
- data.tar.gz: 1245d911d4356d014e616bb387810c3879e8a68919fd1f1f173a4a21cf6c8fe9
3
+ metadata.gz: '081816b1dce310635af2372f9bd944fe3efc4e28a89e5f32be39a83b7abff137'
4
+ data.tar.gz: a1984f13bf1ffedb4999f5f3b761788f6fd01eb3abbedcfb72fd2be0aa6a5b00
5
5
  SHA512:
6
- metadata.gz: 48540c3c00cf275afe01c3194302d48bd0e8e12602f1abd5a81bc99c1cc13ca5fb48fcf630879dc6a851e88559404d210fb6e0d6324a7203a3ad274b18116504
7
- data.tar.gz: 056150df12092b1d16a1b56214d7a268627fe58d7249071c0ef4871aa0c289c184753f2c8468374dd1046beb77515d306c9416033901f0424452ca920ac71993
6
+ metadata.gz: a9f099212f13d0897ed9a17a5281da9b8b2f0a983123f0204d72990c7747c1a3ef11db38bbe846cb48a9c99c8e84adb8d20763377fa9279bae17371629d74b9c
7
+ data.tar.gz: 88d203ec8ce92493f2192658589ba47c9a41543c1e4b7bc78da3aacaf485eaa005fb5beef49ce0f04d02ad3dffbe7c40b65b57aed35bc35baf150928fc3fea25
data/CHANGES.md CHANGED
@@ -1,3 +1,13 @@
1
+ # 8.0.5 - 2026-06-12
2
+
3
+ * Add `quote_schema_name` to safe quote method list (Zsolt Kozaroczy)
4
+ * Fix SQL injection false positive for `compact_blank`/`compact` on permitted params (Arpit Jain)
5
+ * Fix inline render false positive for local named `text` (Arpit Jain)
6
+ * Fix HAML crash on `.raw` calls (Federico Franco)
7
+ * Fix Ruby version parsing - especially for non-CRuby versions (Chris Southerland Jr)
8
+ * Fix `TemplateAliasProcessor#template_name` arity (viralpraxis)
9
+ * Reduce false positives when using shell escaping
10
+
1
11
  # 8.0.4 - 2026-02-26
2
12
 
3
13
  * Load 'date' library for `--ensure-latest`
@@ -122,9 +122,14 @@ class Brakeman::CheckExecute < Brakeman::BaseCheck
122
122
  # should be ignored
123
123
 
124
124
  args.pop if hash?(args.last) && args.length > 2
125
- failure = include_user_input?(args) ||
126
- dangerous_interp?(args) ||
127
- dangerous_string_building?(args)
125
+
126
+ args.each_sexp do |arg|
127
+ failure = include_user_input?(arg) ||
128
+ dangerous_interp?(arg) ||
129
+ dangerous_string_building?(arg)
130
+
131
+ break if failure
132
+ end
128
133
  else
129
134
  failure = include_user_input?(args) ||
130
135
  dangerous_interp?(args) ||
@@ -176,6 +181,8 @@ class Brakeman::CheckExecute < Brakeman::BaseCheck
176
181
  def include_user_input? exp
177
182
  if node_type? exp, :arglist, :dstr, :evstr, :dxstr
178
183
  exp.each_sexp do |e|
184
+ next if shell_escape? e
185
+
179
186
  if res = include_user_input?(e)
180
187
  return res
181
188
  end
@@ -196,7 +203,7 @@ class Brakeman::CheckExecute < Brakeman::BaseCheck
196
203
  # Check for input at start of string
197
204
  exp[1] == "" and
198
205
  node_type? exp[2], :evstr and
199
- has_immediate_user_input? exp[2]
206
+ dangerous? exp[2]
200
207
  else
201
208
  has_immediate_user_input? exp
202
209
  end
@@ -266,6 +273,8 @@ class Brakeman::CheckExecute < Brakeman::BaseCheck
266
273
  end
267
274
 
268
275
  def dangerous_interp? exp
276
+ return if shell_escape? exp
277
+
269
278
  match = include_interp? exp
270
279
  return unless match
271
280
  interp = match.match
@@ -311,7 +311,7 @@ class Brakeman::CheckSQL < Brakeman::BaseCheck
311
311
  end
312
312
 
313
313
  if request_value? arg
314
- unless call? arg and params? arg.target and [:permit, :slice, :to_h, :to_hash, :symbolize_keys].include? arg.method
314
+ unless call? arg and params? arg.target and [:permit, :slice, :to_h, :to_hash, :symbolize_keys, :compact, :compact_blank].include? arg.method
315
315
  # Model.where(params[:where])
316
316
  arg
317
317
  end
@@ -645,7 +645,7 @@ class Brakeman::CheckSQL < Brakeman::BaseCheck
645
645
  locale_call? exp
646
646
  end
647
647
 
648
- QUOTE_METHODS = [:quote, :quote_column_name, :quoted_date, :quote_string, :quote_table_name]
648
+ QUOTE_METHODS = [:quote, :quote_column_name, :quoted_date, :quote_string, :quote_table_name, :quote_schema_name]
649
649
 
650
650
  def quote_call? exp
651
651
  if call? exp.target
@@ -258,12 +258,19 @@ class Brakeman::BaseProcessor < Brakeman::SexpProcessor
258
258
  #Look for "type" of render in options hash
259
259
  #For example, render :file => "blah"
260
260
  if hash? last_arg
261
- hash_iterate(last_arg) do |key, val|
262
- if symbol? key and types_in_hash.include? key.value
263
- type = key.value
264
- value = val
265
- else
266
- rest << key << val
261
+ if type
262
+ #The render type was already determined by a positional argument, so a
263
+ #key in the options hash that happens to match a render type name (e.g.
264
+ #`text:`) is a local passed to the partial/action, not a type directive.
265
+ rest = last_arg
266
+ else
267
+ hash_iterate(last_arg) do |key, val|
268
+ if symbol? key and types_in_hash.include? key.value
269
+ type = key.value
270
+ value = val
271
+ else
272
+ rest << key << val
273
+ end
267
274
  end
268
275
  end
269
276
  end
@@ -6,7 +6,7 @@ class Brakeman::GemProcessor < Brakeman::BasicProcessor
6
6
  def initialize *args
7
7
  super
8
8
  @gem_name_version = /^\s*([-_+.A-Za-z0-9]+) \((\w(\.\w+)*)\)/
9
- @ruby_version = /^\s+ruby (\d\.\d.\d+)/
9
+ @ruby_version = /^\s+ruby (\d+\.\d+\.\d+)/
10
10
  end
11
11
 
12
12
  def process_gems gem_files
@@ -186,6 +186,8 @@ class Brakeman::HamlTemplateProcessor < Brakeman::TemplateProcessor
186
186
 
187
187
  def raw? exp
188
188
  call? exp and
189
- exp.method == :raw
189
+ exp.target.nil? and
190
+ exp.method == :raw and
191
+ exp.first_arg
190
192
  end
191
193
  end
@@ -19,7 +19,9 @@ module Brakeman::RenderHelper
19
19
  end
20
20
  when :default
21
21
  begin
22
- process_template template_name, exp[3], nil, exp.line
22
+ # exp[2] is either the action name (from controller) or :default when no explicit arg
23
+ name_arg = (exp[2].nil? || exp[2] == :default) ? nil : exp[2]
24
+ process_template template_name(name_arg), exp[3], nil, exp.line
23
25
  rescue ArgumentError
24
26
  Brakeman.debug "Problem processing render: #{exp}"
25
27
  end
@@ -187,8 +187,14 @@ class Brakeman::Scanner
187
187
  end
188
188
 
189
189
  if @app_tree.exists? ".ruby-version"
190
- if version = @app_tree.file_path(".ruby-version").read[/(\d\.\d.\d+)/]
191
- tracker.config.set_ruby_version version, @app_tree.file_path(".ruby-version"), 1
190
+ contents = @app_tree.file_path(".ruby-version").read
191
+ # Skip alternative Ruby implementations — the EOL dates Brakeman knows
192
+ # about are MRI's, so a `.ruby-version` of "jruby-10.0.2.0" should not
193
+ # be parsed as MRI 0.0.2 / 10.0.2.
194
+ unless contents =~ /\A\s*(jruby|truffleruby|rbx|rubinius|mruby)\b/i
195
+ if version = contents[/(\d+\.\d+\.\d+)/]
196
+ tracker.config.set_ruby_version version, @app_tree.file_path(".ruby-version"), 1
197
+ end
192
198
  end
193
199
  end
194
200
 
@@ -1,3 +1,3 @@
1
1
  module Brakeman
2
- Version = "8.0.4"
2
+ Version = "8.0.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brakeman-lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.4
4
+ version: 8.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Collins
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2026-02-27 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: minitest
@@ -482,7 +481,6 @@ metadata:
482
481
  mailing_list_uri: https://gitter.im/presidentbeef/brakeman
483
482
  source_code_uri: https://github.com/presidentbeef/brakeman
484
483
  wiki_uri: https://github.com/presidentbeef/brakeman/wiki
485
- post_install_message:
486
484
  rdoc_options: []
487
485
  require_paths:
488
486
  - lib
@@ -497,8 +495,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
497
495
  - !ruby/object:Gem::Version
498
496
  version: '0'
499
497
  requirements: []
500
- rubygems_version: 3.4.19
501
- signing_key:
498
+ rubygems_version: 4.0.3
502
499
  specification_version: 4
503
500
  summary: Security vulnerability scanner for Ruby on Rails.
504
501
  test_files: []