sqreen 1.14.0.beta3-java → 1.14.0-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
  SHA256:
3
- metadata.gz: c4e8efa6908940531662b925941a3bc59413670b80a48c9e758932abd7647b5e
4
- data.tar.gz: bd56cf6968cd82cc05bee7294b3de887064203b352abcc84e15c0945792fd6e0
3
+ metadata.gz: bb56629cb030a8c8ae7e1d3438fe241bbaa0c9f425dc95073498551ee84e53cd
4
+ data.tar.gz: dc28f65a8de23fead674554aaa7c1e076482a009407224e3d9e2b972417fdadc
5
5
  SHA512:
6
- metadata.gz: e6ca675f7878bf9484867e90313b0a058599413b7f29c4f1d502dc103d70d6f90a1a084d0c8c547d74a3a80019b0fd2770d1aca7c2f9668fad90d2da6cf29ff1
7
- data.tar.gz: 11c11c046eb0f92b3c4a15c6b95c2d33d73aba144ec9dd43f11693849e63c9e94c5e8aeae2139e7b8d1e6e274da6d674000a0efd66f4560a36f536bdce0b1c55
6
+ metadata.gz: c494d1f9a2add8ab06cf4db09de8be8c6b8bc36278e4a3c2796c60ad6ebd0419bb3974d32cf872bc3b73942e47861a856111db8b1530b5a36990e1abe5d3448f
7
+ data.tar.gz: 56ee9cc964987ff4c343b84f758c222d6aa7a9971b11e0ebb5342bc0ffc5e31bd9ce86a244f77c21fb671acbe2057ca103f395bf3e4f6184d155696c1bc28f91
@@ -177,7 +177,8 @@ module Sqreen
177
177
 
178
178
  def do_run(client_ip)
179
179
  return nil unless matches_ip? client_ip
180
- e = Sqreen::AttackBlocked.new("Blocked client's IP (action: #{id}). No action is required")
180
+ e = Sqreen::AttackBlocked.new("Blocked client's IP #{client_ip} " \
181
+ "(action: #{id} covering range(s) #{ranges}). No action is required")
181
182
  { :status => :raise, :exception => e }
182
183
  end
183
184
 
@@ -203,7 +204,8 @@ module Sqreen
203
204
 
204
205
  def do_run(client_ip)
205
206
  return nil unless matches_ip? client_ip
206
- Sqreen.log.info "Will request redirect for client with IP #{client_ip} (action: #{id}). "
207
+ Sqreen.log.info "Will request redirect for client with IP #{client_ip} " \
208
+ "(action: #{id} covering range(s) #{ranges})."
207
209
  {
208
210
  :status => :skip,
209
211
  :new_return_value => [303, { 'Location' => @redirect_url }, ['']],
@@ -8,7 +8,11 @@ module Sqreen
8
8
  class Exception < ::StandardError
9
9
  def initialize(msg = nil, *args)
10
10
  super(msg, *args)
11
- Sqreen.log.error msg if msg
11
+ log_message msg if msg
12
+ end
13
+
14
+ def log_message(msg)
15
+ Sqreen.log.error(msg)
12
16
  end
13
17
  end
14
18
 
@@ -24,6 +28,9 @@ module Sqreen
24
28
  # Sqreen users when watching their logs. It should not raise any concern to
25
29
  # them.
26
30
  class AttackBlocked < Exception
31
+ def log_message(msg)
32
+ Sqreen.log.warn(msg)
33
+ end
27
34
  end
28
35
 
29
36
  class NotImplementedYet < Exception
@@ -519,6 +519,18 @@ module Sqreen
519
519
  Sqreen.log.warn "Failed ignoring AttackBlocked on NewRelic: #{e.inspect}"
520
520
  end
521
521
 
522
+ def worker_fork_detection
523
+ # only Puma currently supported
524
+ return unless defined?(Puma::Cluster) && Puma::Cluster.instance_methods.include?(:worker)
525
+ cur_worker_meth = Puma::Cluster.instance_method(:worker)
526
+ Puma::Cluster.class_eval do
527
+ define_method(:worker) do |*args|
528
+ Sqreen.on_forked_worker = true
529
+ cur_worker_meth.bind(self)[*args]
530
+ end
531
+ end
532
+ end
533
+
522
534
  private
523
535
 
524
536
  def split_ip_addresses(ip_addresses)
@@ -89,6 +89,7 @@ module Sqreen
89
89
  def on_start(&block)
90
90
  @calling_pid = Process.pid
91
91
  Init.startup do |app|
92
+ worker_fork_detection
92
93
  sentry_ignore_exceptions
93
94
  newrelic_ignore_errors
94
95
  hook_rack_request(app.class, &block)
@@ -16,6 +16,7 @@ module Sqreen
16
16
  end
17
17
 
18
18
  def on_start(&block)
19
+ worker_fork_detection
19
20
  sentry_ignore_exceptions
20
21
  newrelic_ignore_errors
21
22
  hook_app_build(Sinatra::Base)
@@ -34,9 +34,9 @@ module Sqreen
34
34
  @module = vendored ? Sqreen::MiniRacer : MiniRacer
35
35
  @source = source
36
36
  @recycle_runtime_every = GC_MINI_RACER
37
- @snapshot = @module::Snapshot.new(source)
38
37
  @runtimes = []
39
38
  @tl_key = "SQREEN_MINI_RACER_CONTEXT_#{object_id}".freeze
39
+ snapshot if Sqreen.on_forked_worker? # called to eagerly initialize snapshot
40
40
  unless @@ctx_defined
41
41
  self.class.define_sqreen_context(@module)
42
42
  @@ctx_defined = true
@@ -52,7 +52,7 @@ module Sqreen
52
52
  dead_runtime = true
53
53
  end
54
54
  if dead_runtime
55
- new_runtime = SqreenContext.new(:snapshot => @snapshot)
55
+ new_runtime = SqreenContext.new(:snapshot => snapshot)
56
56
  push_runtime new_runtime
57
57
  mini_racer_context = {
58
58
  :c => 0,
@@ -72,6 +72,10 @@ module Sqreen
72
72
 
73
73
  private
74
74
 
75
+ def snapshot
76
+ @snapshot ||= @module::Snapshot.new(@source)
77
+ end
78
+
75
79
  def push_runtime(runtime)
76
80
  @runtimes.delete_if do |th, runt, _thid|
77
81
  del = th.nil? || !th.weakref_alive? || !th.alive?
@@ -60,6 +60,9 @@ module Sqreen
60
60
  attr_accessor :logged_in
61
61
  alias logged_in? logged_in
62
62
 
63
+ attr_accessor :on_forked_worker
64
+ alias on_forked_worker? on_forked_worker
65
+
63
66
  attr_reader :whitelisted_paths
64
67
  def update_whitelisted_paths(paths)
65
68
  @whitelisted_paths = paths.freeze
@@ -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.14.0.beta3'.freeze
4
+ VERSION = '1.14.0'.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.14.0.beta3
4
+ version: 1.14.0
5
5
  platform: java
6
6
  authors:
7
7
  - Sqreen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-06 00:00:00.000000000 Z
11
+ date: 2018-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -146,9 +146,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
146
146
  version: '0'
147
147
  required_rubygems_version: !ruby/object:Gem::Requirement
148
148
  requirements:
149
- - - ">"
149
+ - - ">="
150
150
  - !ruby/object:Gem::Version
151
- version: 1.3.1
151
+ version: '0'
152
152
  requirements: []
153
153
  rubyforge_project:
154
154
  rubygems_version: 2.7.7