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 +4 -4
- data/lib/sqreen/actions.rb +4 -2
- data/lib/sqreen/exception.rb +8 -1
- data/lib/sqreen/frameworks/generic.rb +12 -0
- data/lib/sqreen/frameworks/rails.rb +1 -0
- data/lib/sqreen/frameworks/sinatra.rb +1 -0
- data/lib/sqreen/js/mini_racer_adapter.rb +6 -2
- data/lib/sqreen/runner.rb +3 -0
- data/lib/sqreen/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb56629cb030a8c8ae7e1d3438fe241bbaa0c9f425dc95073498551ee84e53cd
|
4
|
+
data.tar.gz: dc28f65a8de23fead674554aaa7c1e076482a009407224e3d9e2b972417fdadc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c494d1f9a2add8ab06cf4db09de8be8c6b8bc36278e4a3c2796c60ad6ebd0419bb3974d32cf872bc3b73942e47861a856111db8b1530b5a36990e1abe5d3448f
|
7
|
+
data.tar.gz: 56ee9cc964987ff4c343b84f758c222d6aa7a9971b11e0ebb5342bc0ffc5e31bd9ce86a244f77c21fb671acbe2057ca103f395bf3e4f6184d155696c1bc28f91
|
data/lib/sqreen/actions.rb
CHANGED
@@ -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
|
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}
|
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 }, ['']],
|
data/lib/sqreen/exception.rb
CHANGED
@@ -8,7 +8,11 @@ module Sqreen
|
|
8
8
|
class Exception < ::StandardError
|
9
9
|
def initialize(msg = nil, *args)
|
10
10
|
super(msg, *args)
|
11
|
-
|
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)
|
@@ -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 =>
|
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?
|
data/lib/sqreen/runner.rb
CHANGED
@@ -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
|
data/lib/sqreen/version.rb
CHANGED
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
|
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-
|
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:
|
151
|
+
version: '0'
|
152
152
|
requirements: []
|
153
153
|
rubyforge_project:
|
154
154
|
rubygems_version: 2.7.7
|