prosopite 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +7 -1
- data/lib/prosopite/version.rb +1 -1
- data/lib/prosopite.rb +17 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77276ce50263c0d9e2e4a9e0c525924ac5810367f036d783197222819f8fb312
|
4
|
+
data.tar.gz: b43868ebc87b40d97997db1c7a77fb3ee34cb032a76a0b290adb174c8d04c6d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fc318b3becb5095f93244d8e23699c27e604c43ba7a3dc489ee3939d19b23e26a47eb4957d6355f28fdaa18fb6ecaa2caf27721a03fcadadefa73a5cbcfec7e
|
7
|
+
data.tar.gz: e5954aa6aec45c26722f807dcb2fde6aae4c1090d097cc7172a306cdde9639b734d226826fa1d6dcab59a9d22857dc7901978eb4297287ac49b81a63b23ae0e1
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -182,7 +182,13 @@ WARNING: scan/finish should run before/after **each** test and NOT before/after
|
|
182
182
|
Ignore notifications for call stacks containing one or more substrings:
|
183
183
|
|
184
184
|
```ruby
|
185
|
-
Prosopite.
|
185
|
+
Prosopite.allow_stack_paths = ['substring_in_call_stack']
|
186
|
+
```
|
187
|
+
|
188
|
+
Ignore notifications matching a specific SQL query:
|
189
|
+
|
190
|
+
```ruby
|
191
|
+
Prosopite.ignore_queries = [/regex_match/, "SELECT * from EXACT_STRING_MATCH"]
|
186
192
|
```
|
187
193
|
|
188
194
|
## Scanning code outside controllers or tests
|
data/lib/prosopite/version.rb
CHANGED
data/lib/prosopite.rb
CHANGED
@@ -8,7 +8,14 @@ module Prosopite
|
|
8
8
|
:stderr_logger,
|
9
9
|
:rails_logger,
|
10
10
|
:prosopite_logger,
|
11
|
-
:
|
11
|
+
:allow_stack_paths,
|
12
|
+
:ignore_queries
|
13
|
+
|
14
|
+
def allow_list=(value)
|
15
|
+
puts "Prosopite.allow_list= is deprecated. Use Prosopite.allow_stack_paths= instead."
|
16
|
+
|
17
|
+
self.allow_stack_paths = value
|
18
|
+
end
|
12
19
|
|
13
20
|
def scan
|
14
21
|
tc[:prosopite_scan] ||= false
|
@@ -20,7 +27,7 @@ module Prosopite
|
|
20
27
|
tc[:prosopite_query_holder] = Hash.new { |h, k| h[k] = [] }
|
21
28
|
tc[:prosopite_query_caller] = {}
|
22
29
|
|
23
|
-
@
|
30
|
+
@allow_stack_paths ||= []
|
24
31
|
|
25
32
|
tc[:prosopite_scan] = true
|
26
33
|
|
@@ -75,8 +82,9 @@ module Prosopite
|
|
75
82
|
next unless fingerprints.uniq.size == 1
|
76
83
|
|
77
84
|
kaller = tc[:prosopite_query_caller][location_key]
|
85
|
+
allow_list = (@allow_stack_paths + DEFAULT_ALLOW_LIST)
|
86
|
+
is_allowed = kaller.any? { |f| allow_list.any? { |s| f.include?(s) } }
|
78
87
|
|
79
|
-
is_allowed = kaller.any? { |f| (@allow_list + DEFAULT_ALLOW_LIST).any? { |s| f.include?(s) } }
|
80
88
|
unless is_allowed
|
81
89
|
queries = tc[:prosopite_query_holder][location_key]
|
82
90
|
tc[:prosopite_notifications][queries] = kaller
|
@@ -180,6 +188,11 @@ module Prosopite
|
|
180
188
|
str.split("\n").map { |line| "\e[91m#{line}\e[0m" }.join("\n")
|
181
189
|
end
|
182
190
|
|
191
|
+
def ignore_query?(sql)
|
192
|
+
@ignore_queries ||= []
|
193
|
+
@ignore_queries.any? { |q| q === sql }
|
194
|
+
end
|
195
|
+
|
183
196
|
def subscribe
|
184
197
|
@subscribed ||= false
|
185
198
|
return if @subscribed
|
@@ -187,7 +200,7 @@ module Prosopite
|
|
187
200
|
ActiveSupport::Notifications.subscribe 'sql.active_record' do |_, _, _, _, data|
|
188
201
|
sql, name = data[:sql], data[:name]
|
189
202
|
|
190
|
-
if scan? && name != "SCHEMA" && sql.include?('SELECT') && data[:cached].nil?
|
203
|
+
if scan? && name != "SCHEMA" && sql.include?('SELECT') && data[:cached].nil? && !ignore_query?(sql)
|
191
204
|
location_key = Digest::SHA1.hexdigest(caller.join)
|
192
205
|
|
193
206
|
tc[:prosopite_query_counter][location_key] += 1
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prosopite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mpampis Kostas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-12-
|
11
|
+
date: 2021-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|