immunio 1.1.6 → 1.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/immunio/plugin.rb +8 -5
- data/lib/immunio/plugins/action_dispatch.rb +4 -1
- data/lib/immunio/plugins/action_view.rb +16 -3
- data/lib/immunio/plugins/authlogic.rb +23 -9
- data/lib/immunio/plugins/csrf.rb +4 -1
- data/lib/immunio/plugins/devise.rb +13 -3
- data/lib/immunio/plugins/environment_reporter.rb +3 -2
- data/lib/immunio/plugins/eval.rb +5 -1
- data/lib/immunio/plugins/io.rb +6 -2
- data/lib/immunio/plugins/redirect.rb +5 -2
- data/lib/immunio/plugins/warden.rb +15 -4
- data/lib/immunio/rails.rb +16 -2
- data/lib/immunio/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b00b1a9669f4e9f0ec6b571a88b2d1df883cbf94
|
4
|
+
data.tar.gz: 6fdf549ca4de7c8bf912a1fdcaf7bc00521c4e4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d947098d70f20d0a073789d8742570bb64373fce01429f2207133ac603d612d25534dd362dad87ebfacb57ed0bde6c34038355e336238b28b42a0678bed42f7d
|
7
|
+
data.tar.gz: f4a9b98cce16ba098561bb64bafcadf5fe50f1f9becbbc87549c5df9234f1f55062715274a59c44eadcb37088dc60a19bfe61ce44d59214f5056e9d733579b62
|
data/lib/immunio/plugin.rb
CHANGED
@@ -14,11 +14,13 @@ module Immunio
|
|
14
14
|
class Plugin
|
15
15
|
attr_reader :status
|
16
16
|
attr_accessor :version
|
17
|
+
attr_accessor :hooks
|
17
18
|
|
18
|
-
def initialize(name)
|
19
|
+
def initialize(name, hooks = [])
|
19
20
|
@name = name
|
20
21
|
@status = 'pending'
|
21
22
|
@version = nil
|
23
|
+
@hooks = hooks
|
22
24
|
end
|
23
25
|
|
24
26
|
def loaded!(version)
|
@@ -38,14 +40,15 @@ module Immunio
|
|
38
40
|
end
|
39
41
|
|
40
42
|
def inspect
|
41
|
-
"<#{self.class} name=#{@name.inspect} status=#{@status.inspect} version=#{@version.inspect}>"
|
43
|
+
"<#{self.class} name=#{@name.inspect} status=#{@status.inspect} version=#{@version.inspect} hooks=#{@hooks.inspect}>"
|
42
44
|
end
|
43
45
|
|
44
46
|
def to_msgpack(packer)
|
45
|
-
packer.write_map_header
|
47
|
+
packer.write_map_header 3
|
46
48
|
# `name` is provided as the key in `registered`
|
47
49
|
packer.write('status').write(@status)
|
48
50
|
packer.write('version').write(@version)
|
51
|
+
packer.write('hooks').write(@hooks)
|
49
52
|
end
|
50
53
|
|
51
54
|
def self.registered
|
@@ -76,7 +79,7 @@ module Immunio
|
|
76
79
|
enabled = true
|
77
80
|
end
|
78
81
|
|
79
|
-
plugin = registered[name] = new(name)
|
82
|
+
plugin = registered[name] = new(name, options.fetch(:hooks, []))
|
80
83
|
|
81
84
|
unless enabled # plugin is disabled
|
82
85
|
plugin.disabled!
|
@@ -91,4 +94,4 @@ module Immunio
|
|
91
94
|
end
|
92
95
|
end
|
93
96
|
end
|
94
|
-
end
|
97
|
+
end
|
@@ -29,7 +29,9 @@ module Immunio
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
Immunio::Plugin.load 'ActionDispatch (Cookie)'
|
32
|
+
Immunio::Plugin.load 'ActionDispatch (Cookie)',
|
33
|
+
hooks: %w( bad_cookie ) do |plugin|
|
34
|
+
|
33
35
|
class ActionDispatch::Cookies
|
34
36
|
if defined? SignedCookieJar
|
35
37
|
SignedCookieJar.send :include, Immunio::CookieHooks
|
@@ -47,5 +49,6 @@ Immunio::Plugin.load 'ActionDispatch (Cookie)' do |plugin|
|
|
47
49
|
UpgradeLegacyEncryptedCookieJar.send :include, Immunio::CookieHooks
|
48
50
|
end
|
49
51
|
end
|
52
|
+
|
50
53
|
plugin.loaded! ActionPack::VERSION::STRING
|
51
54
|
end
|
@@ -533,14 +533,23 @@ end
|
|
533
533
|
|
534
534
|
# Load the plugins
|
535
535
|
|
536
|
-
Immunio::Plugin.load
|
536
|
+
Immunio::Plugin.load(
|
537
|
+
'Erubis',
|
538
|
+
feature: 'xss',
|
539
|
+
hooks: %w( template_render_done template_render_var )) do |plugin|
|
540
|
+
|
537
541
|
ActionView::Template::Handlers::Erubis.send :include, Immunio::ErubisHooks
|
542
|
+
|
538
543
|
plugin.loaded! Rails.version
|
539
544
|
end
|
540
545
|
|
541
546
|
ActiveSupport.on_load(:after_initialize) do
|
542
547
|
# Wait after Rails initialization to patch custom template engines.
|
543
|
-
Immunio::Plugin.load
|
548
|
+
Immunio::Plugin.load(
|
549
|
+
'Haml',
|
550
|
+
feature: 'xss',
|
551
|
+
hooks: %w( template_render_done template_render_var )) do |plugin|
|
552
|
+
|
544
553
|
if defined? Haml::Compiler
|
545
554
|
Haml::Compiler.send :include, Immunio::HamlHooks
|
546
555
|
plugin.loaded! Haml::VERSION
|
@@ -552,7 +561,11 @@ ActiveSupport.on_load(:after_initialize) do
|
|
552
561
|
end
|
553
562
|
|
554
563
|
# Hook into rendering process of Rails.
|
555
|
-
Immunio::Plugin.load
|
564
|
+
Immunio::Plugin.load(
|
565
|
+
'ActionView',
|
566
|
+
feature: 'xss',
|
567
|
+
hooks: %w( template_render_done template_render_var )) do |plugin|
|
568
|
+
|
556
569
|
ActionView::TemplateRenderer.send :include, Immunio::TemplateRendererHooks
|
557
570
|
ActionView::Template.send :include, Immunio::TemplateHooks
|
558
571
|
ActionController::Caching::Fragments.send(
|
@@ -1,4 +1,5 @@
|
|
1
|
-
# Register callbacks to Authlogic (https://github.com/binarylogic/authlogic).
|
1
|
+
# Register callbacks to Authlogic (https://github.com/binarylogic/authlogic).
|
2
|
+
# A popular authentication system.
|
2
3
|
|
3
4
|
begin
|
4
5
|
require "authlogic"
|
@@ -6,7 +7,10 @@ rescue LoadError # rubocop:disable Lint/HandleExceptions
|
|
6
7
|
# Ignore
|
7
8
|
end
|
8
9
|
|
9
|
-
Immunio::Plugin.load
|
10
|
+
Immunio::Plugin.load(
|
11
|
+
'Authlogic',
|
12
|
+
hooks: %w( authenticate framework_login framework_user )) do |plugin|
|
13
|
+
|
10
14
|
if defined? Authlogic
|
11
15
|
module Immunio
|
12
16
|
module Authlogic
|
@@ -27,10 +31,12 @@ Immunio::Plugin.load 'Authlogic' do |plugin|
|
|
27
31
|
info = {plugin: "authlogic"}
|
28
32
|
|
29
33
|
if defined?(:record) && record
|
30
|
-
# record is set when already logged in,
|
34
|
+
# record is set when already logged in,
|
35
|
+
# e.g. you are now logging out
|
31
36
|
info[:user_record] = record
|
32
37
|
elsif defined?(:attempted_record) && attempted_record
|
33
|
-
# attempted_record is set when attempting to log in and the
|
38
|
+
# attempted_record is set when attempting to log in and the
|
39
|
+
# user record has been fetched
|
34
40
|
info[:user_record] = attempted_record
|
35
41
|
end
|
36
42
|
|
@@ -45,7 +51,9 @@ Immunio::Plugin.load 'Authlogic' do |plugin|
|
|
45
51
|
|
46
52
|
def immunio_login
|
47
53
|
Immunio::Request.time "plugin", "#{Module.nesting[0]}::#{__method__}" do
|
48
|
-
Immunio.logger.debug
|
54
|
+
Immunio.logger.debug do
|
55
|
+
"Authlogic instrumentation fired for login with opts #{opts}"
|
56
|
+
end
|
49
57
|
Immunio.login opts
|
50
58
|
end
|
51
59
|
end
|
@@ -53,7 +61,9 @@ Immunio::Plugin.load 'Authlogic' do |plugin|
|
|
53
61
|
def immunio_check_failed_login
|
54
62
|
if errors.any?
|
55
63
|
Immunio::Request.time "plugin", "#{Module.nesting[0]}::#{__method__}" do
|
56
|
-
Immunio.logger.debug
|
64
|
+
Immunio.logger.debug do
|
65
|
+
"Authlogic instrumentation fired for before_failure with opts #{opts}"
|
66
|
+
end
|
57
67
|
Immunio.failed_login opts
|
58
68
|
end
|
59
69
|
end
|
@@ -61,14 +71,18 @@ Immunio::Plugin.load 'Authlogic' do |plugin|
|
|
61
71
|
|
62
72
|
def immunio_logout
|
63
73
|
Immunio::Request.time "plugin", "#{Module.nesting[0]}::#{__method__}" do
|
64
|
-
Immunio.logger.debug
|
74
|
+
Immunio.logger.debug do
|
75
|
+
"Authlogic instrumentation fired for logout with opts #{opts}"
|
76
|
+
end
|
65
77
|
Immunio.logout opts
|
66
78
|
end
|
67
79
|
end
|
68
80
|
|
69
81
|
def immunio_set_user
|
70
82
|
Immunio::Request.time "plugin", "#{Module.nesting[0]}::#{__method__}" do
|
71
|
-
Immunio.logger.debug
|
83
|
+
Immunio.logger.debug do
|
84
|
+
"Authlogic instrumentation fired for after_set_user with opts #{opts}"
|
85
|
+
end
|
72
86
|
Immunio.set_user opts
|
73
87
|
end
|
74
88
|
end
|
@@ -81,4 +95,4 @@ Immunio::Plugin.load 'Authlogic' do |plugin|
|
|
81
95
|
|
82
96
|
plugin.loaded! Gem.loaded_specs['authlogic'].version.to_s
|
83
97
|
end
|
84
|
-
end
|
98
|
+
end
|
data/lib/immunio/plugins/csrf.rb
CHANGED
@@ -23,7 +23,10 @@ module Immunio
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
Immunio::Plugin.load 'ActionController (CSRF)'
|
26
|
+
Immunio::Plugin.load 'ActionController (CSRF)',
|
27
|
+
hooks: %w( framework_csrf_check ) do |plugin|
|
28
|
+
|
27
29
|
ActionController::Base.send :include, Immunio::CsrfHook
|
30
|
+
|
28
31
|
plugin.loaded! ActionPack::VERSION::STRING
|
29
32
|
end
|
@@ -6,7 +6,15 @@ rescue LoadError # rubocop:disable Lint/HandleExceptions
|
|
6
6
|
# Ignore
|
7
7
|
end
|
8
8
|
|
9
|
-
Immunio::Plugin.load 'Devise'
|
9
|
+
Immunio::Plugin.load 'Devise',
|
10
|
+
hooks: [
|
11
|
+
'authenticate',
|
12
|
+
'framework_login',
|
13
|
+
'framework_user',
|
14
|
+
'framework_logout',
|
15
|
+
'framework_password_reset'
|
16
|
+
] do |plugin|
|
17
|
+
|
10
18
|
if defined? Devise
|
11
19
|
module Immunio
|
12
20
|
# Hook into password recovery feature to trigger the `framework_password_reset` hook.
|
@@ -19,7 +27,9 @@ Immunio::Plugin.load 'Devise' do |plugin|
|
|
19
27
|
|
20
28
|
def send_reset_password_instructions_with_immunio(attributes={})
|
21
29
|
Request.time "plugin", "#{Module.nesting[0]}::#{__method__}" do
|
22
|
-
Immunio.logger.debug
|
30
|
+
Immunio.logger.debug do
|
31
|
+
"Devise instrumentation fired for send_reset_password_instructions"
|
32
|
+
end
|
23
33
|
|
24
34
|
recoverable = find_or_initialize_with_errors(reset_password_keys, attributes, :not_found)
|
25
35
|
|
@@ -42,4 +52,4 @@ Immunio::Plugin.load 'Devise' do |plugin|
|
|
42
52
|
require 'devise/version'
|
43
53
|
plugin.loaded! Devise::VERSION
|
44
54
|
end
|
45
|
-
end
|
55
|
+
end
|
@@ -52,8 +52,9 @@ module Immunio
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def hostname_ip
|
55
|
-
#
|
56
|
-
|
55
|
+
# Return nil if we can't fetch the hostname with `Socket.gethostname`,
|
56
|
+
# for example if there is no public IPV4 interface.
|
57
|
+
Addrinfo.getaddrinfo(hostname, nil).first.ip_address rescue nil
|
57
58
|
end
|
58
59
|
|
59
60
|
def plugins
|
data/lib/immunio/plugins/eval.rb
CHANGED
@@ -37,8 +37,12 @@ module Immunio
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
Immunio::Plugin.load 'Kernel (Eval)',
|
40
|
+
Immunio::Plugin.load 'Kernel (Eval)',
|
41
|
+
feature: 'eval',
|
42
|
+
hooks: %w( eval ) do |plugin|
|
43
|
+
|
41
44
|
Kernel.send :include, Immunio::KernelEvalHook
|
42
45
|
Kernel.extend Immunio::KernelEvalHook
|
46
|
+
|
43
47
|
plugin.loaded! RUBY_VERSION
|
44
48
|
end
|
data/lib/immunio/plugins/io.rb
CHANGED
@@ -100,14 +100,18 @@ module Immunio
|
|
100
100
|
end
|
101
101
|
|
102
102
|
# Add FileIO hooks if enabled
|
103
|
-
Immunio::Plugin.load 'IO', feature: 'file_io' do |plugin|
|
103
|
+
Immunio::Plugin.load 'IO', feature: 'file_io', hooks: %w( file_io ) do |plugin|
|
104
|
+
|
104
105
|
IO.extend Immunio::IOClassHooks
|
105
106
|
File.extend Immunio::FileClassHooks
|
106
107
|
plugin.loaded! RUBY_VERSION
|
107
108
|
end
|
108
109
|
|
109
110
|
# Add Kernel hooks if enabled
|
110
|
-
Immunio::Plugin.load 'Kernel (shell_command)',
|
111
|
+
Immunio::Plugin.load 'Kernel (shell_command)',
|
112
|
+
feature: 'shell_command',
|
113
|
+
hooks: %w( shell_io ) do |plugin|
|
114
|
+
|
111
115
|
# Both are necessary to hook calling both Kernel.open() and open() etc.
|
112
116
|
Kernel.send :include, Immunio::KernelModuleHooks
|
113
117
|
Kernel.extend Immunio::KernelModuleHooks
|
@@ -22,7 +22,7 @@ module Immunio
|
|
22
22
|
loptions = loptions.call
|
23
23
|
end
|
24
24
|
if loptions.is_a? String then
|
25
|
-
|
25
|
+
_strict_context, loose_context, stack = Immunio::Context.context()
|
26
26
|
Immunio.run_hook! "redirect", "framework_redirect",
|
27
27
|
destination_url: loptions,
|
28
28
|
context_key: loose_context,
|
@@ -36,7 +36,10 @@ module Immunio
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
Immunio::Plugin.load 'ActionController (Redirect)',
|
39
|
+
Immunio::Plugin.load 'ActionController (Redirect)',
|
40
|
+
feature: 'redirect',
|
41
|
+
hooks: %w( framework_redirect ) do |plugin|
|
42
|
+
|
40
43
|
ActionController::Base.send :include, Immunio::RedirectHook
|
41
44
|
|
42
45
|
plugin.loaded! ActionPack::VERSION::STRING
|
@@ -6,12 +6,21 @@ rescue LoadError # rubocop:disable Lint/HandleExceptions
|
|
6
6
|
# Ignore
|
7
7
|
end
|
8
8
|
|
9
|
-
Immunio::Plugin.load 'Warden'
|
9
|
+
Immunio::Plugin.load 'Warden',
|
10
|
+
hooks: [
|
11
|
+
'authenticate',
|
12
|
+
'framework_login',
|
13
|
+
'framework_user',
|
14
|
+
'framework_logout'
|
15
|
+
] do |plugin|
|
16
|
+
|
10
17
|
if defined?(Warden::Manager)
|
11
18
|
class Warden::Manager
|
12
19
|
after_authentication do |user|
|
13
20
|
Immunio::Request.time "plugin", "Warden::Manager.after_authentication" do
|
14
|
-
Immunio.logger.debug
|
21
|
+
Immunio.logger.debug do
|
22
|
+
"Warden instrumentation fired for after_authentication"
|
23
|
+
end
|
15
24
|
Immunio.login user_record: user, plugin: "warden"
|
16
25
|
end
|
17
26
|
end
|
@@ -37,7 +46,9 @@ Immunio::Plugin.load 'Warden' do |plugin|
|
|
37
46
|
Immunio.logger.debug { "Warden instrumentation fired for before_failure" }
|
38
47
|
Immunio.failed_login info
|
39
48
|
else
|
40
|
-
Immunio.logger.debug
|
49
|
+
Immunio.logger.debug do
|
50
|
+
"Failed to find user info for Warden failure, ignoring instead of reporting as failed login"
|
51
|
+
end
|
41
52
|
end
|
42
53
|
end
|
43
54
|
end
|
@@ -71,4 +82,4 @@ Immunio::Plugin.load 'Warden' do |plugin|
|
|
71
82
|
require 'warden/version'
|
72
83
|
plugin.loaded! Warden::VERSION
|
73
84
|
end
|
74
|
-
end
|
85
|
+
end
|
data/lib/immunio/rails.rb
CHANGED
@@ -7,7 +7,18 @@ require_relative "plugins/warden"
|
|
7
7
|
|
8
8
|
module Immunio
|
9
9
|
class Engine < ::Rails::Engine
|
10
|
-
Immunio::Plugin.load 'Middlewares'
|
10
|
+
Immunio::Plugin.load 'Middlewares',
|
11
|
+
hooks: [
|
12
|
+
'http_request_start',
|
13
|
+
'http_request_finish',
|
14
|
+
'http_response_start',
|
15
|
+
'http_request_body_chunk',
|
16
|
+
'http_response_body_chunk',
|
17
|
+
'exception',
|
18
|
+
'framework_route',
|
19
|
+
'framework_session',
|
20
|
+
] do |plugin|
|
21
|
+
|
11
22
|
config.app_middleware.insert 0, HTTPFinisher
|
12
23
|
config.app_middleware.insert_before ActionDispatch::ShowExceptions, HTTPTracker
|
13
24
|
config.app_middleware.insert_after ActionDispatch::DebugExceptions, ExceptionHandler
|
@@ -17,7 +28,10 @@ module Immunio
|
|
17
28
|
|
18
29
|
config.action_dispatch.rescue_responses.merge!('Immunio::RequestBlocked' => :forbidden)
|
19
30
|
|
20
|
-
Immunio::Plugin.load 'ActionRecord',
|
31
|
+
Immunio::Plugin.load 'ActionRecord',
|
32
|
+
feature: 'sqli',
|
33
|
+
hooks: %w( sql_execute ) do |plugin|
|
34
|
+
|
21
35
|
initializer "immunio.active_record", after: "active_record.initialize_database" do
|
22
36
|
ActiveSupport.on_load(:active_record) do
|
23
37
|
require_relative "plugins/active_record"
|
data/lib/immunio/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: immunio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Immunio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|