immunio 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/immunio/context.rb +14 -2
- data/lib/immunio/plugins/action_view.rb +2 -2
- data/lib/immunio/plugins/active_record_relation.rb +2 -0
- data/lib/immunio/plugins/io.rb +29 -10
- data/lib/immunio/version.rb +1 -1
- data/lua-hooks/Makefile +1 -0
- 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: 80267dd0327d92f9af47b91f658a46a3e38cd000
|
4
|
+
data.tar.gz: be17e29bba57536a8d8cdb5a35134cfe64977510
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26355aaa28340307c3a6766ddda207e67484d6e9b0f33601d229660338d1e7becffc3e6140092fd0a10ed7d0bc2d0b3c5f494aaf29fd8e61f66759ac1eb62463
|
7
|
+
data.tar.gz: 218fbac35d91313ebf8dec8ca81cb1be22b05b8b388b79294db8e1750a1ce6f193da04a305b304dcf99544d27e4b503d28af074d98c05f3fed8ee4feafad0b35
|
data/lib/immunio/context.rb
CHANGED
@@ -3,6 +3,14 @@ module Immunio
|
|
3
3
|
RAILS_TEMPLATE_FILTER = Regexp.new("(.*(_erb|_haml))__+\\d+_\\d+(.*)")
|
4
4
|
# Cache for contexts (named in tribute to our buddy Adam Back who invented proof of work)
|
5
5
|
@@hash_cache = {}
|
6
|
+
FILE_CHECKSUM_CACHE = Hash.new do |cache, filepath|
|
7
|
+
begin
|
8
|
+
contents = IOHooks.paused { File.read(filepath) }
|
9
|
+
cache[filepath] = Digest::SHA1.hexdigest(contents)
|
10
|
+
rescue StandardError
|
11
|
+
cache[filepath] = ""
|
12
|
+
end
|
13
|
+
end
|
6
14
|
|
7
15
|
# Calculate context hashes and a stack trace. Additional data, in the form
|
8
16
|
# of a String, may be provided to mix into the strict context hash.
|
@@ -29,7 +37,7 @@ module Immunio
|
|
29
37
|
# are filtered by the Gem regex.
|
30
38
|
locations = caller(1).map do |frame|
|
31
39
|
frame = frame.split(":", 3)
|
32
|
-
{path: frame[0], line: frame[1], label: frame[2]}
|
40
|
+
{ path: frame[0], line: frame[1], label: frame[2] }
|
33
41
|
end
|
34
42
|
|
35
43
|
locations.each do |frame|
|
@@ -44,7 +52,7 @@ module Immunio
|
|
44
52
|
# relocation. If there's no rails root, or the path doesn't start with
|
45
53
|
# the rails root, just use the filename part.
|
46
54
|
if defined?(Rails) && defined?(Rails.root) &&
|
47
|
-
|
55
|
+
Rails.root && frame[:path].start_with?(Rails.root.to_s)
|
48
56
|
strict_path = frame[:path].sub(Rails.root.to_s, '')
|
49
57
|
else
|
50
58
|
strict_path = File.basename(frame[:path])
|
@@ -64,6 +72,10 @@ module Immunio
|
|
64
72
|
strict_context_rope << ":"
|
65
73
|
strict_context_rope << frame[:label]
|
66
74
|
|
75
|
+
# Include checksums of file contents in the strict context
|
76
|
+
checksum = FILE_CHECKSUM_CACHE[frame[:path]]
|
77
|
+
strict_context_rope << ":#{checksum}" unless checksum.blank?
|
78
|
+
|
67
79
|
# Remove pathname from the loose context. The goal here is to prevent
|
68
80
|
# upgrading gem versions from changing the loose context key, so for instance
|
69
81
|
# users don't have to rebuild their whitelists every time they update a gem
|
@@ -55,7 +55,7 @@ module Immunio
|
|
55
55
|
old_formats = context.lookup_context.formats
|
56
56
|
begin
|
57
57
|
context.lookup_context.formats = @template.formats
|
58
|
-
refreshed = @template.refresh(context)
|
58
|
+
refreshed = Immunio::IOHooks.paused { @template.refresh(context) }
|
59
59
|
ensure
|
60
60
|
context.lookup_context.formats = old_formats
|
61
61
|
end
|
@@ -158,7 +158,7 @@ module Immunio
|
|
158
158
|
def render(context)
|
159
159
|
load_source context
|
160
160
|
# Don't handle templates with no source (inline text templates).
|
161
|
-
|
161
|
+
unless has_source?
|
162
162
|
rendered = yield
|
163
163
|
rendered.instance_variable_set("@__immunio_processed", true)
|
164
164
|
return rendered
|
@@ -129,8 +129,10 @@ module Immunio
|
|
129
129
|
|
130
130
|
caller_method = frame.label
|
131
131
|
caller_line = frame.lineno
|
132
|
+
checksum = Immunio::Context::FILE_CHECKSUM_CACHE[frame.path]
|
132
133
|
|
133
134
|
data = "Relation for #{name}, method called: #{method}, caller: #{caller_method}:#{caller_line}"
|
135
|
+
data << ", checksum: #{checksum}" unless checksum.blank?
|
134
136
|
else
|
135
137
|
data = "Relation for #{name}, method called: #{method}"
|
136
138
|
end
|
data/lib/immunio/plugins/io.rb
CHANGED
@@ -3,6 +3,20 @@ require_relative '../context'
|
|
3
3
|
module Immunio
|
4
4
|
module IOHooks
|
5
5
|
|
6
|
+
def self.paused
|
7
|
+
old_paused = Thread.current["immunio.file_io_paused"]
|
8
|
+
Thread.current["immunio.file_io_paused"] = true
|
9
|
+
begin
|
10
|
+
yield
|
11
|
+
ensure
|
12
|
+
Thread.current["immunio.file_io_paused"] = old_paused
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.paused?
|
17
|
+
!!Thread.current["immunio.file_io_paused"]
|
18
|
+
end
|
19
|
+
|
6
20
|
def self.inject(mod, name, methods)
|
7
21
|
mod.class_eval <<-EOF
|
8
22
|
def self.extended(base) # def self.extended(base)
|
@@ -21,16 +35,21 @@ module Immunio
|
|
21
35
|
methods.each do |method|
|
22
36
|
mod.class_eval <<-EOF
|
23
37
|
def #{method}_with_immunio(*args, &block) # def read_with_immunio(*args, &block)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
38
|
+
if Immunio::IOHooks.paused?
|
39
|
+
#{method}_without_immunio(*args, &block)
|
40
|
+
else
|
41
|
+
Request.time "plugin", "IO::#{method}" do #
|
42
|
+
strict_context, loose_context, stack, loose_stack = Immunio::Context.context()
|
43
|
+
|
44
|
+
Immunio.run_hook! "io", "file_io", # Immunio.run_hook! "io", "open",
|
45
|
+
method: "#{name}#{method}", # open_method: "IO.read",
|
46
|
+
parameters: args, # parameters: args
|
47
|
+
stack: loose_stack, #
|
48
|
+
context_key: loose_context, #
|
49
|
+
cwd: Dir.pwd
|
50
|
+
Request.pause "plugin", "IO::#{method}" do #
|
51
|
+
#{method}_without_immunio(*args, &block) # read_without_immunio(*args, &block)
|
52
|
+
end
|
34
53
|
end
|
35
54
|
end
|
36
55
|
end # end
|
data/lib/immunio/version.rb
CHANGED
data/lua-hooks/Makefile
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.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Immunio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|