sqreen 1.7.1 → 1.7.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b7c0d876ee5f24abd72e726834023d2f9629169f
4
- data.tar.gz: 71bd73ae7b3513b8727286abba6488ccd704d341
3
+ metadata.gz: 5741aa7c3b34891c2a790746a3bdaa41b89af92b
4
+ data.tar.gz: bf1170f3d02dc780352e4c55a5f26862ce0a340e
5
5
  SHA512:
6
- metadata.gz: 395f0a6db93a2ce37ab1500c3bf16aa5f44ab93cb94701a7bc1bbf7803d68ff2380b05dbde439c89c19ba6e80a3425b99c227c1304f1ea5220d57e15bb5fc959
7
- data.tar.gz: ce8eaa36bc6224afe30e1838183562e11e724415901de1fd91c243af6b94367e4d044e41c73ffa0e81fb8a953a0598c74b32185b915d616a8d1dcb988d3ae7de
6
+ metadata.gz: 87ca7a7ae12ab3b762c12b4c051d0fbf7bce0f16a4b11d9b80462aff8ba01a2f3ce4c8ddcd41c41cc9c93ddb4f920384f6812410b0c4089ffd3c78e2812c4490
7
+ data.tar.gz: d93a22ee357be92f2fe75b877f2be5af7d7b947ca605102743a241c7592b300d8fd43ad2cb19c7cc707bb832512edf56a5df6fbaf05851dc5fb64b91b123bf8f
@@ -61,6 +61,8 @@ module Sqreen
61
61
 
62
62
  returns = []
63
63
  callbacks.each do |cb|
64
+ # If record_request is part of callbacks we should filter after it ran
65
+ next if cb.whitelisted?
64
66
  rule = cb.rule_name if cb.respond_to?(:rule_name)
65
67
  Sqreen.log.debug { "running pre cb #{cb}" }
66
68
  Sqreen::PerformanceNotifications.instrument("Callbacks/#{rule || cb.class.name}/pre") do
@@ -57,6 +57,7 @@ module Sqreen
57
57
  next unless val.respond_to?(:each)
58
58
  next if val.respond_to?(:seek)
59
59
  val.each do |v|
60
+ next if !v.is_a?(String) || (!matcher.min_size.nil? && v.size < matcher.min_size)
60
61
  next if matcher.match(v).nil?
61
62
  infos = {
62
63
  'id' => id,
@@ -7,6 +7,7 @@ module Sqreen
7
7
  module Rules
8
8
  # matcher behavior
9
9
  module Matcher
10
+ attr_reader :min_size
10
11
  def self.prepare_re_pattern(value, options, case_sensitive)
11
12
  res = 0
12
13
  res |= Regexp::MULTILINE if options.include?('multiline')
@@ -33,6 +34,7 @@ module Sqreen
33
34
  'equals'.freeze => lambda { |value, str| str == value },
34
35
  }
35
36
 
37
+ sizes = []
36
38
  patterns.each do |entry|
37
39
  next unless entry
38
40
  type = entry['type']
@@ -56,25 +58,28 @@ module Sqreen
56
58
  end
57
59
  @string[opt] = { :ci => [], :cs => [] } unless @string.key?(opt)
58
60
  @string[opt][case_type] << val
59
-
61
+ sizes << entry.fetch('min_length') { val.size }
60
62
  when 'regexp'
61
63
  pattern = Matcher.prepare_re_pattern(val, opt, case_sensitive)
62
64
  next unless pattern
63
65
  @regexp_patterns << pattern
66
+ sizes << entry['min_length']
64
67
  else
65
68
  raise Sqreen::Exception, "No such matcher type #{type}"
66
69
  end
67
70
  end
68
71
 
72
+ @min_size = sizes.min unless sizes.any?(&:nil?)
73
+
69
74
  return unless [@regexp_patterns, @string].map(&:empty?).all?
70
75
  msg = "no key 'regexp' nor 'match' in data (had #{@data.keys})"
71
76
  raise Sqreen::Exception, msg
72
77
  end
73
78
 
74
79
  def match(str)
75
- return if str.nil? || str.empty?
76
- str = enforce_encoding(str)
77
- istr = str.downcase
80
+ return if str.nil? || str.empty? || !str.is_a?(String)
81
+ str = enforce_encoding(str) unless str.ascii_only?
82
+ istr = str.downcase unless @string.empty?
78
83
 
79
84
  @string.each do |type, cases|
80
85
  fun = @funs[type]
@@ -100,7 +105,6 @@ module Sqreen
100
105
  end
101
106
  else
102
107
  @regexp_patterns.each do |p|
103
- warn(Encoding.compatible?(p, str).inspect)
104
108
  return p if p.match(str)
105
109
  end
106
110
  end
@@ -110,8 +114,6 @@ module Sqreen
110
114
  private
111
115
 
112
116
  def enforce_encoding(str)
113
- return str unless str.is_a?(String)
114
- return str if str.ascii_only?
115
117
  encoded8bit = str.encoding.name == 'ASCII-8BIT'
116
118
  return str if !encoded8bit && str.valid_encoding?
117
119
  str.chars.map do |v|
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2015 Sqreen. All Rights Reserved.
2
2
  # Please refer to our terms for more information: https://www.sqreen.io/terms.html
3
3
  module Sqreen
4
- VERSION = '1.7.1'.freeze
4
+ VERSION = '1.7.2'.freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sqreen
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.1
4
+ version: 1.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sqreen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-10 00:00:00.000000000 Z
11
+ date: 2017-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: execjs