immunio 1.0.17 → 1.0.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +24 -0
- data/README.md +2 -2
- data/lib/immunio/logger.rb +0 -1
- data/lib/immunio/plugins/warden.rb +5 -5
- data/lib/immunio/version.rb +1 -1
- data/lib/immunio_tasks/version_bump.rake +44 -0
- data/lib/immunio_tasks/version_bumper.rb +128 -0
- data/lua-hooks/Makefile +10 -1
- data/lua-hooks/ext/perf/luacpu.c +18 -18
- data/lua-hooks/ext/perf/lualoadavg.c +2 -2
- data/lua-hooks/ext/perf/luameminfo.c +1 -1
- data/lua-hooks/ext/perf/luaoslib.c +2 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa6484d2fd07102fbdc20e1e0efb80e896fe7fd3
|
4
|
+
data.tar.gz: 1f3f3b0b1489dc425ac437f349b53b581719b4cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12ec429dfc0384009851ae4cc9f27db31678e13a45b39974c0e72fdea2f6dbeb832aa8847bb277f5adbd2918ec385a6a4c5eef8d594d6de79e11dfbbc61ba3cc
|
7
|
+
data.tar.gz: 818548e67dfa6d9e954903aa2da1d2e54745541164eb3de70bbc32bac74dc58adca741fd109c346c86dc96513fa85f1877c5f07a480cd66189fb9d9eaa7b2997
|
data/LICENSE
CHANGED
@@ -187,6 +187,30 @@ subject to the following conditions:
|
|
187
187
|
out of or in connection with the Software or the use or other dealings in the
|
188
188
|
Software.
|
189
189
|
|
190
|
+
This product includes content covered by the following license:
|
191
|
+
|
192
|
+
The MIT License (MIT)
|
193
|
+
|
194
|
+
Copyright (c) 2015 Boris Nagaev
|
195
|
+
|
196
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
197
|
+
of this software and associated documentation files (the "Software"), to deal
|
198
|
+
in the Software without restriction, including without limitation the rights
|
199
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
200
|
+
copies of the Software, and to permit persons to whom the Software is
|
201
|
+
furnished to do so, subject to the following conditions:
|
202
|
+
|
203
|
+
The above copyright notice and this permission notice shall be included in all
|
204
|
+
copies or substantial portions of the Software.
|
205
|
+
|
206
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
207
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
208
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
209
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
210
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
211
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
212
|
+
SOFTWARE.
|
213
|
+
|
190
214
|
|
191
215
|
All other components of this product are
|
192
216
|
Copyright (c) 2015 Immunio, Inc. All rights reserved.
|
data/README.md
CHANGED
@@ -22,9 +22,9 @@ require 'immunio'
|
|
22
22
|
|
23
23
|
## Configuration
|
24
24
|
|
25
|
-
The agent key and secret can be configured
|
25
|
+
The agent key and secret can be configured in a configuration file at *config/immunio.yml*.
|
26
26
|
|
27
|
-
Optionally,
|
27
|
+
Optionally, the agent key and secret can be set using the `IMMUNIO_KEY` and `IMMUNIO_SECRET` environment variables, which will take precedence.
|
28
28
|
|
29
29
|
```yaml
|
30
30
|
key: "my-key"
|
data/lib/immunio/logger.rb
CHANGED
@@ -57,11 +57,11 @@ if defined?(Warden::Manager)
|
|
57
57
|
|
58
58
|
# Force lookup of user info for all requests.
|
59
59
|
def call_with_immunio(env)
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
60
|
+
call_without_immunio(env)
|
61
|
+
ensure
|
62
|
+
Immunio::Request.time "plugin", "#{Module.nesting[0]}::#{__method__}" do
|
63
|
+
env['warden'].user if env['warden']
|
64
|
+
end
|
65
65
|
end
|
66
66
|
alias :call_without_immunio :call
|
67
67
|
alias :call :call_with_immunio
|
data/lib/immunio/version.rb
CHANGED
@@ -0,0 +1,44 @@
|
|
1
|
+
require_relative 'version_bumper'
|
2
|
+
|
3
|
+
namespace 'version' do
|
4
|
+
YES_TRUE_REGEX = /yes|y|true|t/
|
5
|
+
|
6
|
+
def test_mode?
|
7
|
+
!!(ENV.fetch('TEST', 'no').downcase =~ YES_TRUE_REGEX)
|
8
|
+
end
|
9
|
+
|
10
|
+
def quiet_mode?
|
11
|
+
!!(ENV.fetch('QUIET', 'yes').downcase =~ YES_TRUE_REGEX)
|
12
|
+
end
|
13
|
+
|
14
|
+
task :setup do
|
15
|
+
@bumper = VersionBumper.new(test_mode?, quiet_mode?)
|
16
|
+
@bumper.status
|
17
|
+
abort "You must be on a clean master branch!" unless VersionBumper.on_clean_master?
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "Show status"
|
21
|
+
task :status => [ :setup ] do
|
22
|
+
end
|
23
|
+
|
24
|
+
namespace 'release' do
|
25
|
+
desc "Prepare a new release"
|
26
|
+
task :prepare => [ :setup ] do
|
27
|
+
@bumper.prepare
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "Bump version"
|
32
|
+
task :bump => [ :setup ] do
|
33
|
+
new_version = @bumper.prompt_for_new_version
|
34
|
+
@bumper.ask_and_bump_version(new_version)
|
35
|
+
end
|
36
|
+
|
37
|
+
namespace :bump do
|
38
|
+
desc "Bump version to development"
|
39
|
+
task :development => [ :setup ] do
|
40
|
+
abort "Version already set for development" if VersionBumper.development?
|
41
|
+
@bumper.bump_development_version
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require_relative '../immunio/version'
|
2
|
+
require 'highline'
|
3
|
+
|
4
|
+
class VersionBumper
|
5
|
+
def self.current_version
|
6
|
+
Immunio::VERSION
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.version_file
|
10
|
+
@version_file ||= File.join Dir.pwd, 'lib/', 'immunio', 'version.rb'
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.current_branch
|
14
|
+
%x[git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3].strip
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.on_master?
|
18
|
+
current_branch == 'master'
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.clean_branch?
|
22
|
+
%x[git status --porcelain --ignore-submodules].split.count == 0
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.on_clean_master?
|
26
|
+
on_master? && clean_branch?
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.development?
|
30
|
+
current_version =~ /master/
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
def initialize(test_mode, quiet_mode)
|
35
|
+
@test_mode = test_mode
|
36
|
+
@quiet_mode = quiet_mode
|
37
|
+
end
|
38
|
+
|
39
|
+
attr_reader :test_mode, :quiet_mode
|
40
|
+
|
41
|
+
def status
|
42
|
+
cli.say "<%= color('You are not on the master branch!', BOLD) %>" unless self.class.on_master?
|
43
|
+
cli.say "<%= color('There are uncommitted changes OR untracked files!', BOLD) %>" unless self.class.clean_branch?
|
44
|
+
cli.say "Current version is: #{self.class.current_version}"
|
45
|
+
end
|
46
|
+
|
47
|
+
def prepare
|
48
|
+
if cli.agree("Are you sure? (yes/no)")
|
49
|
+
exec 'git submodule init' # When we have a fresh clone
|
50
|
+
exec 'git fetch origin'
|
51
|
+
exec 'git clean -fxd'
|
52
|
+
exec 'git submodule foreach --recursive git clean -fxd'
|
53
|
+
exec 'git submodule update'
|
54
|
+
cli.say 'Now run `bundle exec rake version:bump`'
|
55
|
+
else
|
56
|
+
cli.say 'Nothing done.'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def prompt_for_new_version
|
61
|
+
@new_version ||= cli.ask('New version? ') do |v|
|
62
|
+
v.default = self.class.current_version.sub('.master', '')
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def ask_and_bump_version(version)
|
67
|
+
unless version_valid?
|
68
|
+
cli.say 'Version is unchanged'
|
69
|
+
return
|
70
|
+
end
|
71
|
+
|
72
|
+
if cli.agree("Bump version to #{version}? (yes/no)")
|
73
|
+
bump_version(version)
|
74
|
+
else
|
75
|
+
cli.say 'Nothing done.'
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def bump_development_version
|
80
|
+
return if self.class.development?
|
81
|
+
|
82
|
+
arr = self.class.current_version.split('.')
|
83
|
+
new_patch_level = (arr.last.to_i + 1).to_s
|
84
|
+
version = (arr[0...2] << new_patch_level).join('.') << '.master'
|
85
|
+
|
86
|
+
ask_and_bump_version(version)
|
87
|
+
end
|
88
|
+
|
89
|
+
private
|
90
|
+
|
91
|
+
def exec(cmd)
|
92
|
+
echo = test_mode ? 'echo' : ''
|
93
|
+
puts "=> #{echo} #{cmd}" unless quiet_mode
|
94
|
+
%x[#{echo} #{cmd}]
|
95
|
+
end
|
96
|
+
|
97
|
+
def cli
|
98
|
+
@cli ||= HighLine.new
|
99
|
+
end
|
100
|
+
|
101
|
+
def version_valid?
|
102
|
+
@new_version != self.class.current_version
|
103
|
+
end
|
104
|
+
|
105
|
+
def bump_version(new_version)
|
106
|
+
return unless self.class.on_clean_master?
|
107
|
+
|
108
|
+
cli.say "Bumping version to v#{new_version}"
|
109
|
+
update_version_file(new_version)
|
110
|
+
commit_changes(new_version)
|
111
|
+
end
|
112
|
+
|
113
|
+
def update_version_file(new_version)
|
114
|
+
cli.say "Updating #{self.class.version_file}"
|
115
|
+
cli.say exec(%Q[sed -i '' 's/#{self.class.current_version}/#{new_version}/' #{self.class.version_file}])
|
116
|
+
end
|
117
|
+
|
118
|
+
def commit_changes(new_version)
|
119
|
+
cli.say "Committing changes"
|
120
|
+
if new_version =~ /master/
|
121
|
+
cli.say exec(%Q[git commit -a -m \"Open v#{new_version} for development\"])
|
122
|
+
else
|
123
|
+
cli.say exec(%Q[git commit -a -m \"Bump agent version to v#{new_version}\"])
|
124
|
+
cli.say "Next, run `gem_push=no bundle exec rake release`"
|
125
|
+
cli.say "Then, run `bundle exec rake version:bump:development`"
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
data/lua-hooks/Makefile
CHANGED
@@ -25,6 +25,7 @@ LUA_SRC = \
|
|
25
25
|
lib/hooks.lua \
|
26
26
|
lib/idn.lua \
|
27
27
|
lib/lexgraph.lua \
|
28
|
+
lib/lru.lua \
|
28
29
|
lib/neturl.lua \
|
29
30
|
lib/paths.lua \
|
30
31
|
lib/perf.lua \
|
@@ -35,6 +36,7 @@ LUA_SRC = \
|
|
35
36
|
lib/semver.lua \
|
36
37
|
lib/sha1.lua \
|
37
38
|
lib/snap.lua \
|
39
|
+
lib/term.lua \
|
38
40
|
lib/utils.lua \
|
39
41
|
lib/lexers/bash_dqstr.lua \
|
40
42
|
lib/lexers/bash.lua \
|
@@ -42,6 +44,7 @@ LUA_SRC = \
|
|
42
44
|
lib/lexers/css.lua \
|
43
45
|
lib/lexers/html.lua \
|
44
46
|
lib/lexers/javascript.lua \
|
47
|
+
lib/lexers/markers.lua \
|
45
48
|
lib/lexer.lua \
|
46
49
|
lib/hooks/authenticate.lua \
|
47
50
|
lib/hooks/bad_cookie.lua \
|
@@ -53,9 +56,11 @@ LUA_SRC = \
|
|
53
56
|
lib/hooks/framework_csrf_check.lua \
|
54
57
|
lib/hooks/framework_login.lua \
|
55
58
|
lib/hooks/framework_password_reset.lua \
|
59
|
+
lib/hooks/framework_account_created.lua \
|
56
60
|
lib/hooks/framework_redirect.lua \
|
57
61
|
lib/hooks/framework_session.lua \
|
58
62
|
lib/hooks/framework_user.lua \
|
63
|
+
lib/hooks/framework_route.lua \
|
59
64
|
lib/hooks/http_request_finish.lua \
|
60
65
|
lib/hooks/http_request_start.lua \
|
61
66
|
lib/hooks/http_response_start.lua \
|
@@ -160,12 +165,16 @@ clean: cleanhooks
|
|
160
165
|
rm -rf build
|
161
166
|
find . -name \*.o -delete
|
162
167
|
|
163
|
-
|
164
168
|
test: ${CLI} ${INIT_HOOK} lint ${MIN_SRCS}
|
165
169
|
@rm -f test_failed
|
166
170
|
@for file in test/*_test.lua; do printf "\nRunning $$file\n"; TEST_BUILT_HOOKS=1 ./${CLI} $$file || touch test_failed; done
|
167
171
|
@test ! -f test_failed
|
168
172
|
|
173
|
+
enable-console: cleanhooks
|
174
|
+
git update-index --assume-unchanged lib/term.lua
|
175
|
+
cp lib/term.lua.dev lib/term.lua
|
176
|
+
make
|
177
|
+
|
169
178
|
lint: ${INIT_HOOK}
|
170
179
|
@# Scan all lua files for lines with trailing spaces
|
171
180
|
@# The leading `!` negates the logic, so this target fails if trailing
|
data/lua-hooks/ext/perf/luacpu.c
CHANGED
@@ -5,32 +5,32 @@
|
|
5
5
|
#include "lua.h"
|
6
6
|
#include "lauxlib.h"
|
7
7
|
|
8
|
-
/* Show overall CPU utilization of the system
|
8
|
+
/* Show overall CPU utilization of the system
|
9
9
|
* This is a part of the post http://phoxis.org/2013/09/05/finding-overall-and-per-core-cpu-utilization
|
10
10
|
*/
|
11
11
|
|
12
12
|
#define BUF_MAX 1024
|
13
13
|
|
14
|
-
int
|
14
|
+
int
|
15
15
|
read_fields (FILE *fp, unsigned long long int *fields) {
|
16
16
|
int retval;
|
17
17
|
char buffer[BUF_MAX];
|
18
18
|
if (!fgets (buffer, BUF_MAX, fp)) {
|
19
|
-
|
19
|
+
return 0;
|
20
20
|
}
|
21
|
-
retval = sscanf (buffer, "cpu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu",
|
22
|
-
&fields[0],
|
23
|
-
&fields[1],
|
24
|
-
&fields[2],
|
25
|
-
&fields[3],
|
26
|
-
&fields[4],
|
27
|
-
&fields[5],
|
28
|
-
&fields[6],
|
29
|
-
&fields[7],
|
30
|
-
&fields[8],
|
31
|
-
&fields[9]);
|
21
|
+
retval = sscanf (buffer, "cpu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu",
|
22
|
+
&fields[0],
|
23
|
+
&fields[1],
|
24
|
+
&fields[2],
|
25
|
+
&fields[3],
|
26
|
+
&fields[4],
|
27
|
+
&fields[5],
|
28
|
+
&fields[6],
|
29
|
+
&fields[7],
|
30
|
+
&fields[8],
|
31
|
+
&fields[9]);
|
32
32
|
if (retval < 4) {
|
33
|
-
fprintf (stderr, "Error reading /proc/stat cpu field\n");
|
33
|
+
//fprintf (stderr, "Error reading /proc/stat cpu field\n");
|
34
34
|
return 0;
|
35
35
|
}
|
36
36
|
return 1;
|
@@ -48,7 +48,7 @@ lua_cpuload(lua_State *L) {
|
|
48
48
|
|
49
49
|
fp = fopen ("/proc/stat", "r");
|
50
50
|
if (fp == NULL) {
|
51
|
-
|
51
|
+
return 0;
|
52
52
|
}
|
53
53
|
|
54
54
|
if (!read_fields (fp, fields)) {
|
@@ -70,7 +70,7 @@ lua_cpuload(lua_State *L) {
|
|
70
70
|
|
71
71
|
for (i=0, total_tick = 0; i<10; i++) {
|
72
72
|
total_tick += fields[i];
|
73
|
-
}
|
73
|
+
}
|
74
74
|
idle = fields[3];
|
75
75
|
|
76
76
|
del_total_tick = total_tick - total_tick_old;
|
@@ -88,7 +88,7 @@ lua_stat(lua_State *L) {
|
|
88
88
|
FILE *fp;
|
89
89
|
char buf[3000];
|
90
90
|
if ((fp=fopen("/proc/stat","r"))==NULL) {
|
91
|
-
|
91
|
+
return 0;
|
92
92
|
}
|
93
93
|
else {
|
94
94
|
fread(buf, 1, 3000, fp);
|
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
/*https://www.centos.org/docs/5/html/5.1/Deployment_Guide/s2-proc-loadavg.html
|
10
10
|
Gives load average in regard to both the CPU and IO over time, as well as additional
|
11
|
-
data used by uptime and other commands.
|
11
|
+
data used by uptime and other commands.
|
12
12
|
*/
|
13
13
|
|
14
14
|
/* Immunio Lua bindings */
|
@@ -18,7 +18,7 @@ lua_loadavg(lua_State *L) {
|
|
18
18
|
char c[100];
|
19
19
|
FILE *fp;
|
20
20
|
if ((fp=fopen("/proc/loadavg","r"))==NULL) {
|
21
|
-
|
21
|
+
return 0;
|
22
22
|
}
|
23
23
|
if (fgets(c, 100, fp) != NULL) {
|
24
24
|
lua_pushstring(L, c);
|
@@ -8,7 +8,8 @@
|
|
8
8
|
#include "lj_err.h"
|
9
9
|
|
10
10
|
static int os_clock(lua_State *L) {
|
11
|
-
|
11
|
+
lua_Number clk = ((lua_Number)clock())*(1.0/(lua_Number)CLOCKS_PER_SEC);
|
12
|
+
lua_pushnumber(L, clk);
|
12
13
|
return 1;
|
13
14
|
}
|
14
15
|
|
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.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Immunio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -164,6 +164,8 @@ files:
|
|
164
164
|
- lib/immunio/utils.rb
|
165
165
|
- lib/immunio/version.rb
|
166
166
|
- lib/immunio/vm.rb
|
167
|
+
- lib/immunio_tasks/version_bump.rake
|
168
|
+
- lib/immunio_tasks/version_bumper.rb
|
167
169
|
- lua-hooks/Makefile
|
168
170
|
- lua-hooks/ext/all.c
|
169
171
|
- lua-hooks/ext/libinjection/COPYING
|
@@ -445,9 +447,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
445
447
|
version: '0'
|
446
448
|
requirements: []
|
447
449
|
rubyforge_project:
|
448
|
-
rubygems_version: 2.4.5
|
450
|
+
rubygems_version: 2.4.5.1
|
449
451
|
signing_key:
|
450
452
|
specification_version: 4
|
451
453
|
summary: Immunio Ruby agent
|
452
454
|
test_files: []
|
453
|
-
has_rdoc:
|