sqreen 1.7.1-java → 1.7.2-java

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: 050e9e1dd1e941ee11ff26906ce3042b3f1c074a
4
- data.tar.gz: f2bfd3b7e4e3d1c84cd0c372e974830e46d5a16e
3
+ metadata.gz: 8223ebd05a7bc08f9b17998ec2f44cddb5e1e958
4
+ data.tar.gz: e203f67c6f078dd1003a1e47a351e0f41df83987
5
5
  SHA512:
6
- metadata.gz: 7e601c8a9a906e6a33405216b1440ec7d4a8e08b7865b73870687b48d1dea8d4355a814e8b83b587743dd6083f71436089a572e821248205edfbf251775796a1
7
- data.tar.gz: 248697508a0d1b63be0d20686841df7cd25aad411096c03be9c90d2bf098494daad349636e0d1fe69cbc9565a35452a2c601296c73131f94989fca9a7d50d34f
6
+ metadata.gz: a5e7309f49b33393de0480239146c6f89265dfae21fadcfc2183964f388f6a00e1259fe30269c716733846b6349b12555bf7e0f9c8112b0c28ad2db4fa363b88
7
+ data.tar.gz: 71e8adf17dbe6cbcfea8467160f3b5560ab0ff71429ab33bf1fa84db366bc0c7e9b56cae2e118144db5829b2a77b8ece1e6359f304bfa5cad657be84d4e7f259
@@ -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: java
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