immunio 0.15.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +234 -0
  3. data/README.md +147 -0
  4. data/bin/immunio +5 -0
  5. data/lib/immunio.rb +29 -0
  6. data/lib/immunio/agent.rb +260 -0
  7. data/lib/immunio/authentication.rb +96 -0
  8. data/lib/immunio/blocked_app.rb +38 -0
  9. data/lib/immunio/channel.rb +432 -0
  10. data/lib/immunio/cli.rb +39 -0
  11. data/lib/immunio/context.rb +114 -0
  12. data/lib/immunio/errors.rb +43 -0
  13. data/lib/immunio/immunio_ca.crt +45 -0
  14. data/lib/immunio/logger.rb +87 -0
  15. data/lib/immunio/plugins/action_dispatch.rb +45 -0
  16. data/lib/immunio/plugins/action_view.rb +431 -0
  17. data/lib/immunio/plugins/active_record.rb +707 -0
  18. data/lib/immunio/plugins/active_record_relation.rb +370 -0
  19. data/lib/immunio/plugins/authlogic.rb +80 -0
  20. data/lib/immunio/plugins/csrf.rb +24 -0
  21. data/lib/immunio/plugins/devise.rb +40 -0
  22. data/lib/immunio/plugins/environment_reporter.rb +69 -0
  23. data/lib/immunio/plugins/eval.rb +51 -0
  24. data/lib/immunio/plugins/exception_handler.rb +55 -0
  25. data/lib/immunio/plugins/gems_tracker.rb +5 -0
  26. data/lib/immunio/plugins/haml.rb +36 -0
  27. data/lib/immunio/plugins/http_finisher.rb +50 -0
  28. data/lib/immunio/plugins/http_tracker.rb +203 -0
  29. data/lib/immunio/plugins/io.rb +96 -0
  30. data/lib/immunio/plugins/redirect.rb +42 -0
  31. data/lib/immunio/plugins/warden.rb +66 -0
  32. data/lib/immunio/processor.rb +234 -0
  33. data/lib/immunio/rails.rb +26 -0
  34. data/lib/immunio/request.rb +139 -0
  35. data/lib/immunio/rufus_lua_ext/ref.rb +27 -0
  36. data/lib/immunio/rufus_lua_ext/state.rb +157 -0
  37. data/lib/immunio/rufus_lua_ext/table.rb +137 -0
  38. data/lib/immunio/rufus_lua_ext/utils.rb +13 -0
  39. data/lib/immunio/version.rb +5 -0
  40. data/lib/immunio/vm.rb +291 -0
  41. data/lua-hooks/ext/all.c +78 -0
  42. data/lua-hooks/ext/bitop/README +22 -0
  43. data/lua-hooks/ext/bitop/bit.c +189 -0
  44. data/lua-hooks/ext/extconf.rb +38 -0
  45. data/lua-hooks/ext/libinjection/COPYING +37 -0
  46. data/lua-hooks/ext/libinjection/libinjection.h +65 -0
  47. data/lua-hooks/ext/libinjection/libinjection_html5.c +847 -0
  48. data/lua-hooks/ext/libinjection/libinjection_html5.h +54 -0
  49. data/lua-hooks/ext/libinjection/libinjection_sqli.c +2301 -0
  50. data/lua-hooks/ext/libinjection/libinjection_sqli.h +295 -0
  51. data/lua-hooks/ext/libinjection/libinjection_sqli_data.h +9349 -0
  52. data/lua-hooks/ext/libinjection/libinjection_xss.c +531 -0
  53. data/lua-hooks/ext/libinjection/libinjection_xss.h +21 -0
  54. data/lua-hooks/ext/libinjection/lualib.c +109 -0
  55. data/lua-hooks/ext/lpeg/HISTORY +90 -0
  56. data/lua-hooks/ext/lpeg/lpcap.c +537 -0
  57. data/lua-hooks/ext/lpeg/lpcap.h +43 -0
  58. data/lua-hooks/ext/lpeg/lpcode.c +986 -0
  59. data/lua-hooks/ext/lpeg/lpcode.h +34 -0
  60. data/lua-hooks/ext/lpeg/lpeg-128.gif +0 -0
  61. data/lua-hooks/ext/lpeg/lpeg.html +1429 -0
  62. data/lua-hooks/ext/lpeg/lpprint.c +244 -0
  63. data/lua-hooks/ext/lpeg/lpprint.h +35 -0
  64. data/lua-hooks/ext/lpeg/lptree.c +1238 -0
  65. data/lua-hooks/ext/lpeg/lptree.h +77 -0
  66. data/lua-hooks/ext/lpeg/lptypes.h +149 -0
  67. data/lua-hooks/ext/lpeg/lpvm.c +355 -0
  68. data/lua-hooks/ext/lpeg/lpvm.h +58 -0
  69. data/lua-hooks/ext/lpeg/makefile +55 -0
  70. data/lua-hooks/ext/lpeg/re.html +498 -0
  71. data/lua-hooks/ext/lpeg/test.lua +1409 -0
  72. data/lua-hooks/ext/lua-cmsgpack/CMakeLists.txt +45 -0
  73. data/lua-hooks/ext/lua-cmsgpack/README.md +115 -0
  74. data/lua-hooks/ext/lua-cmsgpack/lua_cmsgpack.c +957 -0
  75. data/lua-hooks/ext/lua-cmsgpack/test.lua +570 -0
  76. data/lua-hooks/ext/lua-snapshot/LICENSE +7 -0
  77. data/lua-hooks/ext/lua-snapshot/Makefile +12 -0
  78. data/lua-hooks/ext/lua-snapshot/README.md +18 -0
  79. data/lua-hooks/ext/lua-snapshot/dump.lua +15 -0
  80. data/lua-hooks/ext/lua-snapshot/snapshot.c +455 -0
  81. data/lua-hooks/ext/lua/COPYRIGHT +34 -0
  82. data/lua-hooks/ext/lua/lapi.c +1087 -0
  83. data/lua-hooks/ext/lua/lapi.h +16 -0
  84. data/lua-hooks/ext/lua/lauxlib.c +652 -0
  85. data/lua-hooks/ext/lua/lauxlib.h +174 -0
  86. data/lua-hooks/ext/lua/lbaselib.c +659 -0
  87. data/lua-hooks/ext/lua/lcode.c +831 -0
  88. data/lua-hooks/ext/lua/lcode.h +76 -0
  89. data/lua-hooks/ext/lua/ldblib.c +398 -0
  90. data/lua-hooks/ext/lua/ldebug.c +638 -0
  91. data/lua-hooks/ext/lua/ldebug.h +33 -0
  92. data/lua-hooks/ext/lua/ldo.c +519 -0
  93. data/lua-hooks/ext/lua/ldo.h +57 -0
  94. data/lua-hooks/ext/lua/ldump.c +164 -0
  95. data/lua-hooks/ext/lua/lfunc.c +174 -0
  96. data/lua-hooks/ext/lua/lfunc.h +34 -0
  97. data/lua-hooks/ext/lua/lgc.c +710 -0
  98. data/lua-hooks/ext/lua/lgc.h +110 -0
  99. data/lua-hooks/ext/lua/linit.c +38 -0
  100. data/lua-hooks/ext/lua/liolib.c +556 -0
  101. data/lua-hooks/ext/lua/llex.c +463 -0
  102. data/lua-hooks/ext/lua/llex.h +81 -0
  103. data/lua-hooks/ext/lua/llimits.h +128 -0
  104. data/lua-hooks/ext/lua/lmathlib.c +263 -0
  105. data/lua-hooks/ext/lua/lmem.c +86 -0
  106. data/lua-hooks/ext/lua/lmem.h +49 -0
  107. data/lua-hooks/ext/lua/loadlib.c +705 -0
  108. data/lua-hooks/ext/lua/loadlib_rel.c +760 -0
  109. data/lua-hooks/ext/lua/lobject.c +214 -0
  110. data/lua-hooks/ext/lua/lobject.h +381 -0
  111. data/lua-hooks/ext/lua/lopcodes.c +102 -0
  112. data/lua-hooks/ext/lua/lopcodes.h +268 -0
  113. data/lua-hooks/ext/lua/loslib.c +243 -0
  114. data/lua-hooks/ext/lua/lparser.c +1339 -0
  115. data/lua-hooks/ext/lua/lparser.h +82 -0
  116. data/lua-hooks/ext/lua/lstate.c +214 -0
  117. data/lua-hooks/ext/lua/lstate.h +169 -0
  118. data/lua-hooks/ext/lua/lstring.c +111 -0
  119. data/lua-hooks/ext/lua/lstring.h +31 -0
  120. data/lua-hooks/ext/lua/lstrlib.c +871 -0
  121. data/lua-hooks/ext/lua/ltable.c +588 -0
  122. data/lua-hooks/ext/lua/ltable.h +40 -0
  123. data/lua-hooks/ext/lua/ltablib.c +287 -0
  124. data/lua-hooks/ext/lua/ltm.c +75 -0
  125. data/lua-hooks/ext/lua/ltm.h +54 -0
  126. data/lua-hooks/ext/lua/lua.c +392 -0
  127. data/lua-hooks/ext/lua/lua.def +131 -0
  128. data/lua-hooks/ext/lua/lua.h +388 -0
  129. data/lua-hooks/ext/lua/lua.rc +28 -0
  130. data/lua-hooks/ext/lua/lua_dll.rc +26 -0
  131. data/lua-hooks/ext/lua/luac.c +200 -0
  132. data/lua-hooks/ext/lua/luac.rc +1 -0
  133. data/lua-hooks/ext/lua/luaconf.h +763 -0
  134. data/lua-hooks/ext/lua/luaconf.h.in +724 -0
  135. data/lua-hooks/ext/lua/luaconf.h.orig +763 -0
  136. data/lua-hooks/ext/lua/lualib.h +53 -0
  137. data/lua-hooks/ext/lua/lundump.c +227 -0
  138. data/lua-hooks/ext/lua/lundump.h +36 -0
  139. data/lua-hooks/ext/lua/lvm.c +767 -0
  140. data/lua-hooks/ext/lua/lvm.h +36 -0
  141. data/lua-hooks/ext/lua/lzio.c +82 -0
  142. data/lua-hooks/ext/lua/lzio.h +67 -0
  143. data/lua-hooks/ext/lua/print.c +227 -0
  144. data/lua-hooks/ext/luautf8/README.md +152 -0
  145. data/lua-hooks/ext/luautf8/lutf8lib.c +1274 -0
  146. data/lua-hooks/ext/luautf8/unidata.h +3064 -0
  147. data/lua-hooks/lib/boot.lua +254 -0
  148. data/lua-hooks/lib/encode.lua +4 -0
  149. data/lua-hooks/lib/lexers/LICENSE +21 -0
  150. data/lua-hooks/lib/lexers/bash.lua +134 -0
  151. data/lua-hooks/lib/lexers/bash_dqstr.lua +62 -0
  152. data/lua-hooks/lib/lexers/css.lua +216 -0
  153. data/lua-hooks/lib/lexers/html.lua +106 -0
  154. data/lua-hooks/lib/lexers/javascript.lua +68 -0
  155. data/lua-hooks/lib/lexers/lexer.lua +1575 -0
  156. data/lua-hooks/lib/lexers/markers.lua +33 -0
  157. metadata +308 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1c331edca1ddff7a5fcb72c6b6c28242157ff552
4
+ data.tar.gz: 23ceaa2748c24eae7a80d952278887361aab6d9f
5
+ SHA512:
6
+ metadata.gz: 2de2e6af290768ab138e0ad91a5ffa1dca0e3b80011c0eb45c4ff5b34241d2ef15911cb7e91a24579dee7c02babb8b688ff491516d81ccbffeec2be888d56336
7
+ data.tar.gz: c45c6cb2bcd16d4d317a444100d90713229c1599e7920c9d7cd203e0697dda0eca3d366cfed0d18f4cb0742ccba4a96ce86b01d51b1eeb485c9256dfc3811f8b
data/LICENSE ADDED
@@ -0,0 +1,234 @@
1
+ This product includes content covered by the following license:
2
+ Copyright (C) 1994-2008 Lua.org, PUC-Rio.
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in
12
+ all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.
21
+
22
+ This product includes content covered by the following license:
23
+ Copyright (C) 2008-2012 Mike Pall.
24
+
25
+ Permission is hereby granted, free of charge, to any person obtaining a copy
26
+ of this software and associated documentation files (the "Software"), to deal
27
+ in the Software without restriction, including without limitation the rights
28
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
29
+ copies of the Software, and to permit persons to whom the Software is
30
+ furnished to do so, subject to the following conditions:
31
+
32
+ The above copyright notice and this permission notice shall be included in
33
+ all copies or substantial portions of the Software.
34
+
35
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
38
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
39
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
40
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
41
+ THE SOFTWARE.
42
+
43
+ This product includes content covered by the following license:
44
+ Copyright 2012, 2013, 2014
45
+ Nick Galbreath -- nickg [at] client9 [dot] com
46
+ http://www.client9.com/projects/libinjection/
47
+
48
+ All rights reserved.
49
+
50
+ Redistribution and use in source and binary forms, with or without
51
+ modification, are permitted provided that the following conditions are
52
+ met:
53
+
54
+ Redistributions of source code must retain the above copyright
55
+ notice, this list of conditions and the following disclaimer.
56
+
57
+ Redistributions in binary form must reproduce the above copyright
58
+ notice, this list of conditions and the following disclaimer in the
59
+ documentation and/or other materials provided with the distribution.
60
+
61
+ Neither the name of libinjection nor the names of its
62
+ contributors may be used to endorse or promote products derived from
63
+ this software without specific prior written permission.
64
+
65
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
66
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
67
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
68
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
69
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
70
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
71
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
72
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
73
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
74
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
75
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
76
+
77
+ This product includes content covered by the following license:
78
+ Copyright (C) 1994–2015 Lua.org, PUC-Rio.
79
+
80
+ Permission is hereby granted, free of charge,
81
+ to any person obtaining a copy of this software and
82
+ associated documentation files (the "Software"),
83
+ to deal in the Software without restriction,
84
+ including without limitation the rights to use,
85
+ copy, modify, merge, publish, distribute, sublicense,
86
+ and/or sell copies of the Software,
87
+ and to permit persons to whom the Software is
88
+ furnished to do so,
89
+ subject to the following conditions:
90
+
91
+ The above copyright notice and this permission notice
92
+ shall be included in all copies or substantial portions of the Software.
93
+
94
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
95
+ EXPRESS OR IMPLIED,
96
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
97
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
98
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
99
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
100
+ TORT OR OTHERWISE, ARISING FROM,
101
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
102
+ THE SOFTWARE.
103
+
104
+ This product includes content covered by the following license:
105
+ Copyright (C) 2012 Salvatore Sanfilippo. All rights reserved.
106
+
107
+ Permission is hereby granted, free of charge, to any person obtaining
108
+ a copy of this software and associated documentation files (the
109
+ "Software"), to deal in the Software without restriction, including
110
+ without limitation the rights to use, copy, modify, merge, publish,
111
+ distribute, sublicense, and/or sell copies of the Software, and to
112
+ permit persons to whom the Software is furnished to do so, subject to
113
+ the following conditions:
114
+
115
+ The above copyright notice and this permission notice shall be
116
+ included in all copies or substantial portions of the Software.
117
+
118
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
119
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
120
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
121
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
122
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
123
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
124
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
125
+
126
+ This product includes content covered by the following license:
127
+ Copyright (c) 2007-2015 Mitchell
128
+
129
+ Permission is hereby granted, free of charge, to any person obtaining a copy
130
+ of this software and associated documentation files (the "Software"), to deal
131
+ in the Software without restriction, including without limitation the rights
132
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
133
+ copies of the Software, and to permit persons to whom the Software is
134
+ furnished to do so, subject to the following conditions:
135
+
136
+ The above copyright notice and this permission notice shall be included in
137
+ all copies or substantial portions of the Software.
138
+
139
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
140
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
141
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
142
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
143
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
144
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
145
+ THE SOFTWARE.
146
+
147
+ This product includes content covered by the following license:
148
+ Copyright (c) 2012, Daniel Lindsley
149
+ All rights reserved.
150
+
151
+ Redistribution and use in source and binary forms, with or without
152
+ modification, are permitted provided that the following conditions are met:
153
+
154
+ * Redistributions of source code must retain the above copyright notice, this
155
+ list of conditions and the following disclaimer.
156
+ * Redistributions in binary form must reproduce the above copyright notice,
157
+ this list of conditions and the following disclaimer in the documentation
158
+ and/or other materials provided with the distribution.
159
+ * Neither the name of the base64 nor the names of its contributors may be
160
+ used to endorse or promote products derived from this software without
161
+ specific prior written permission.
162
+
163
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
164
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
165
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
166
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
167
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
168
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
169
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
170
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
171
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
172
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
173
+
174
+ This product includes content covered by the following license:
175
+ Copyright (c) 2012 codingow.com
176
+
177
+ Permission is hereby granted, free of charge, to any person obtaining
178
+ a copy of this software and associated documentation files (the
179
+ "Software"), to deal in the Software without restriction, including
180
+ without limitation the rights to use, copy, modify, merge, publish,
181
+ distribute, sublicense, and/or sell copies of the Software, and to
182
+ permit persons to whom the Software is furnished to do so, subject to
183
+ the following conditions:
184
+
185
+ The above copyright notice and this permission notice shall be included
186
+ in all copies or substantial portions of the Software.
187
+
188
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
189
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
190
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
191
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
192
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
193
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
194
+ DEALINGS IN THE SOFTWARE.
195
+
196
+
197
+ All other components of this product are
198
+ Copyright (c) 2015 Immunio, Inc. All rights reserved.
199
+
200
+ Certain inventions disclosed in this file may be claimed within
201
+ patents owned or patent applications filed by Immunio, Inc. or third
202
+ parties.
203
+
204
+ Subject to the terms of this notice, Immunio grants you a
205
+ nonexclusive, nontransferable license, without the right to
206
+ sublicense, to (a) install and execute one copy of these files on any
207
+ number of workstations owned or controlled by you and (b) distribute
208
+ verbatim copies of these files to third parties. As a condition to the
209
+ foregoing grant, you must provide this notice along with each copy you
210
+ distribute and you must not remove, alter, or obscure this notice. All
211
+ other use, reproduction, modification, distribution, or other
212
+ exploitation of these files is strictly prohibited, except as may be set
213
+ forth in a separate written license agreement between you and Immunio.
214
+ The terms of any such license agreement will control over this
215
+ notice. The license stated above will be automatically terminated and
216
+ revoked if you exceed its scope or violate any of the terms of this
217
+ notice.
218
+
219
+ This License does not grant permission to use the trade names,
220
+ trademarks, service marks, or product names of Immunio, except as
221
+ required for reasonable and customary use in describing the origin of
222
+ this file and reproducing the content of this notice. You may not
223
+ mark or brand this file with any trade name, trademarks, service
224
+ marks, or product names other than the original brand (if any)
225
+ provided by Immunio.
226
+
227
+ Unless otherwise expressly agreed by Immunio in a separate written
228
+ license agreement, these files are provided AS IS, WITHOUT WARRANTY OF
229
+ ANY KIND, including without any implied warranties of MERCHANTABILITY,
230
+ FITNESS FOR A PARTICULAR PURPOSE, TITLE, or NON-INFRINGEMENT. As a
231
+ condition to your use of these files, you are solely responsible for
232
+ such use. Immunio will have no liability to you for direct,
233
+ indirect, consequential, incidental, special, or punitive damages or
234
+ for lost profits or data.
@@ -0,0 +1,147 @@
1
+ # Immunio Ruby Agent
2
+
3
+ ## Installation
4
+
5
+ Add the private Immunio Gemfury repo and the gem itself to your Gemfile:
6
+
7
+ ```ruby
8
+ gem 'immunio', source: 'https://6kxysjCKxsZz3uR6wgas@gem.fury.io/immunio/'
9
+ ```
10
+
11
+ Run Bundler to install the gem:
12
+
13
+ ```sh
14
+ bundle install
15
+ ```
16
+
17
+ Note that if your application is not using Bundler, require the Immunio package:
18
+
19
+ ```ruby
20
+ require 'immunio'
21
+ ```
22
+
23
+ ## Configuration
24
+
25
+ The agent key and secret can be configured via the `IMMUNIO_KEY` and `IMMUNIO_SECRET` environment variables.
26
+
27
+ Optionally, a configuration file can be provided in *config/immunio.yml* which will take precedence over the environment variables:
28
+
29
+ ```yaml
30
+ key: "my-key"
31
+ secret: "my-secret"
32
+ ```
33
+
34
+ The Immunio agent is enabled by default in all rails environments. It can be enabled in production only in your Gemfile:
35
+
36
+ ```ruby
37
+ gem immunio', group: :production
38
+ ```
39
+
40
+ You can also modify the secret and key for different environments to report to different apps, or you can disable the agent by setting `agent_enabled: false` in the configuration or `IMMUNIO_AGENT_ENABLED=0` in the environment.
41
+
42
+ ## Handling blocked requests
43
+
44
+ By default, Immunio will return a plain text *403 Forbidden* response whenever it blocks a request for security reasons.
45
+
46
+ To customize this behavior, use the `Immunio.blocked_app` option, which should be a valid [Rack application](http://rack.github.io/):
47
+
48
+ ```ruby
49
+ Immunio.blocked_app = -> env do
50
+ [
51
+ 403,
52
+ { 'Content-Type' => 'text/html' },
53
+ ActionController::DataStreaming::FileBody.new('public/403.html')
54
+ ]
55
+ end
56
+ ```
57
+
58
+ ## Authentication API
59
+
60
+ If you're using [Devise](https://github.com/plataformatec/devise) or [Authlogic](https://github.com/binarylogic/authlogic), Immunio will automatically hook into your authentication system to protect you against attacks.
61
+
62
+ If you're not using one of the above frameworks, you will need to manually tell Immunio when authentication occurs. Use the following methods to do so.
63
+
64
+ - After a user logs in: `Immunio.login user`
65
+ - After a failed login attempt: `Immunio.failed_login`
66
+ - After a user logs out: `Immunio.logout`
67
+ - After the current user is changed (or set): `Immunio.set_user`
68
+ - After a user requests a password reset: `Immunio.password_reset`
69
+ - After a failed requests for resetting a password: `Immunio.failed_password_reset`
70
+
71
+ **Note:** `Immunio.set_user` should be called for every request where user data is available, not just when authentication mechanisms are used.
72
+
73
+ These methods take an options hash with the following information:
74
+
75
+ * user_id: String or Number
76
+ * username: String
77
+ * email: String
78
+ * user_record: ActiveRecord object for the user
79
+ * reason: String (for failures)
80
+
81
+ Here's an example:
82
+
83
+ ```ruby
84
+ class ApplicationController
85
+ def current_user=(user)
86
+ Immunio.set_user user_record: user
87
+ # Store user ...
88
+ end
89
+ end
90
+
91
+ class SessionsController < ApplicationController
92
+ # POST /login
93
+ def create
94
+ if user = User.authenticate(params[:user])
95
+ Immunio.login user_record: user
96
+ self.current_user = user
97
+ # ...
98
+ else
99
+ Immunio.failed_login username: params[:user]
100
+ # ...
101
+ end
102
+ end
103
+
104
+ # DELETE /logout
105
+ def destroy
106
+ Immunio.logout user_record: current_user
107
+ # ...
108
+ end
109
+ end
110
+ ```
111
+
112
+ ## Support
113
+
114
+ - Ruby 2.0 and up
115
+ - Rails 3.2 to 4.2
116
+
117
+ ## Building the gem
118
+
119
+ To build the pure Ruby gem:
120
+
121
+ ```sh
122
+ $ rake gem
123
+ ```
124
+
125
+ To build with bundled pre-compiled C extensions:
126
+
127
+ ```sh
128
+ $ rake native gem
129
+ ```
130
+
131
+ For cross-compilation, see https://github.com/luislavena/rake-compiler#cross-compilation---the-future-is-now.
132
+
133
+ ## Testing
134
+
135
+ To run tests (under Rails 4.2):
136
+
137
+ ```sh
138
+ $ rake test
139
+ ```
140
+
141
+ To run tests under Rails 3.2:
142
+
143
+ ```sh
144
+ $ export RAILS_VERSION=3.2
145
+ $ bundle update rails
146
+ $ rake test
147
+ ```
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'immunio/cli'
4
+
5
+ Immunio::CLI.start
@@ -0,0 +1,29 @@
1
+ module Immunio
2
+ DIR = File.expand_path(File.dirname(__FILE__))
3
+
4
+ def self.activate!
5
+ require_relative "immunio/agent"
6
+ require_relative "immunio/authentication"
7
+
8
+ agent # Force load agent
9
+ end
10
+
11
+ # Load plugins (after agent is loaded)
12
+ def self.activate_plugins!
13
+ require_relative "immunio/plugins/action_view"
14
+ # NOTE immunio/plugins/active_record is loaded after ActiveRecord is configured in rails.rb
15
+ require_relative "immunio/plugins/action_dispatch"
16
+ require_relative "immunio/plugins/csrf"
17
+ require_relative "immunio/plugins/io"
18
+ require_relative "immunio/plugins/devise"
19
+ require_relative "immunio/plugins/warden"
20
+ require_relative "immunio/plugins/authlogic"
21
+ require_relative "immunio/plugins/redirect"
22
+ require_relative "immunio/plugins/eval"
23
+
24
+ # Load and activate Rails engine
25
+ require_relative "immunio/rails"
26
+ end
27
+ end
28
+
29
+ Immunio.activate!
@@ -0,0 +1,260 @@
1
+ require "set"
2
+ require "yaml"
3
+
4
+ require_relative "channel"
5
+ require_relative "processor"
6
+
7
+
8
+
9
+ module Immunio
10
+ @agent = nil
11
+
12
+ # Plugins that are enabled by default. Override using the `plugins_enabled`
13
+ # and `plugins_disabled` configuration settings.
14
+ DEFAULT_PLUGINS = ["xss", "file_io", "redirect", "sqli", "eval", "shell_command"]
15
+
16
+ CONFIG_FILENAME = "immunio.yml"
17
+
18
+ class Agent
19
+ include ActiveSupport::Configurable
20
+
21
+ # These configuration accessors will be available via the `config` method.
22
+ # NB: :key must be accessed using config[:key] and not config.key
23
+ config_accessor :key, :secret
24
+
25
+ config_accessor :hello_url
26
+
27
+ config_accessor :log_file
28
+ config_accessor :log_level
29
+ config_accessor :log_timings
30
+ config_accessor :log_context_data
31
+
32
+ config_accessor :http_timeout
33
+
34
+ config_accessor :max_send_queue_size
35
+ config_accessor :max_report_interval
36
+ config_accessor :min_report_size
37
+ config_accessor :max_report_size
38
+ config_accessor :max_report_bytes
39
+
40
+ # These two values control the exponential backoff behaviour during
41
+ # communication failure.
42
+ config_accessor :initial_delay_ms
43
+ config_accessor :max_delay_ms
44
+
45
+ # How long should the Agent wait for the Immunio Service to provide an
46
+ # initial ruleset. Any "Falsy" value means don't wait at all.
47
+ config_accessor :ready_timeout
48
+
49
+ # Control which plugins will be enabled on startup.
50
+ # `plugins_active` contains the default list of plugins. Other plugins
51
+ # can be added to the list by putting them in `plugins_enabled` or
52
+ # removed from the list by adding the to `plugins_disabled`.
53
+ config_accessor :plugins_active
54
+ config_accessor :plugins_disabled
55
+ config_accessor :plugins_enabled
56
+
57
+ # Set to `true` to enable automatic reloading of hook handlers from files.
58
+ config_accessor :dev_mode
59
+
60
+ # Set to `true` to enable lua debugging urls etc.
61
+ config_accessor :debug_mode
62
+
63
+ # Set to `false` to disable the agent.
64
+ config_accessor :agent_enabled
65
+
66
+ # Set to an array of safe methods for creating ActiveSupport::SafeBuffers
67
+ # with script tags.
68
+ config_accessor :safe_script_tag_contexts
69
+
70
+ # Any settings specified in vm_data are used to override agent
71
+ # configuration returned from the server. Mostly used for debugging
72
+ # purposes.
73
+ config_accessor :vm_data
74
+
75
+ def initialize
76
+ Immunio.logger.info "Initializing agent version #{VERSION} for process #{Process.pid}"
77
+
78
+ config.key = config.secret = "-default-"
79
+ config.hello_url = "https://agent.immun.io/"
80
+ config.log_file = "log/immunio.log"
81
+ config.log_level = "info"
82
+ config.log_timings = false
83
+ config.log_context_data = false
84
+ config.http_timeout = 30 # seconds
85
+ config.max_send_queue_size = 500 # messages
86
+ config.max_report_interval = 10 # seconds
87
+ config.min_report_size = 25 # messages
88
+ config.max_report_size = 50 # messages
89
+ config.max_report_bytes = 1500000 # Just shy of 1.5 megs
90
+ config.initial_delay_ms = 100 # milliseconds
91
+ config.max_delay_ms = 10 * 60 * 1000 # milliseconds
92
+ config.dev_mode = false
93
+ config.debug_mode = false
94
+ config.ready_timeout = 0
95
+ # Default list of active plugins
96
+ config.plugins_active = DEFAULT_PLUGINS.to_set
97
+ # Default to empty lists for enabled and disabled
98
+ config.plugins_enabled = []
99
+ config.plugins_disabled = []
100
+ config.agent_enabled = true
101
+ config.safe_script_tag_contexts = []
102
+ config.vm_data = {}
103
+
104
+ # Be sure all config attributes have a type before this call:
105
+ load_config
106
+
107
+ Immunio::switch_to_real_logger(config.log_file, config.log_level)
108
+
109
+ if !config.agent_enabled then
110
+ Immunio.logger.info "Agent disabled in config"
111
+ return
112
+ end
113
+
114
+ @vmfactory = VMFactory.new(config[:key], config.secret, config.dev_mode,
115
+ config.debug_mode)
116
+
117
+ @channel = Channel.new(config)
118
+ @channel.on_sending do
119
+ @vmfactory.current_state
120
+ end
121
+
122
+ # Link things together. The vmfactory needs to know about updates
123
+ # to the code and data, and the channel needs to know when everything
124
+ # is up to date.
125
+ have_code = config.dev_mode
126
+ have_data = false
127
+ @channel.on_message do |message|
128
+ case message[:type]
129
+ when "engine.vm.code.update"
130
+ # Don't update code in dev_mode
131
+ unless config.dev_mode
132
+ @vmfactory.update_code message[:version], message[:code]
133
+ have_code = true
134
+ if have_data
135
+ @channel.set_ready
136
+ end
137
+ end
138
+ when "engine.vm.data.update"
139
+ @vmfactory.update_data message[:version], message[:data]
140
+ have_data = true
141
+ if have_code
142
+ @channel.set_ready
143
+ end
144
+ end
145
+ end
146
+
147
+ @processor = Processor.new(@channel, @vmfactory, config)
148
+ end
149
+
150
+ def load_config
151
+ Immunio.logger.debug "Default configuration: #{config}"
152
+
153
+ # Try loading file from some standard locations. First match is used.
154
+ locations = []
155
+ locations << Rails.root.join("config", CONFIG_FILENAME) if defined?(Rails.root) && Rails.root
156
+ locations << File.join("config", CONFIG_FILENAME)
157
+
158
+ locations.each do |location|
159
+ Immunio.logger.debug "Trying to find config file at #{location}"
160
+ begin
161
+ realpath = File.realpath(location) # Raises exception if file doesn't exist
162
+ Immunio.logger.debug "Found config file at #{realpath}"
163
+ options = YAML.load_file(realpath).symbolize_keys
164
+ config.update options
165
+ Immunio.logger.debug "Configuration after loading from file: #{config}"
166
+ break
167
+ rescue SystemCallError => e
168
+ Immunio.logger.debug "Failed to load config: #{e}"
169
+ end
170
+ end
171
+
172
+ # Load private config from env vars.
173
+ # Set the type of the same as set in initialize
174
+ config.keys.each do |key|
175
+ if ENV["IMMUNIO_#{key.upcase}"] then
176
+ new_value = ENV["IMMUNIO_#{key.upcase}"]
177
+ case config[key]
178
+ when String
179
+ config[key] = new_value
180
+ when Fixnum
181
+ config[key] = Integer(new_value)
182
+ when TrueClass, FalseClass
183
+ config[key] = !(new_value =~ (/^(true|t|yes|y|1)$/i)).nil?
184
+ when Array
185
+ config[key] = new_value.split(/[\s,]+/)
186
+ when Set
187
+ config[key] = new_value.split(/[\s,]+/).to_set
188
+ else
189
+ raise ArgumentError, "Unknown ENV conversion for #{config[key].class}"
190
+ end
191
+ end
192
+ end
193
+
194
+ Immunio.logger.debug "Configuration after evaluating env vars: #{config}"
195
+
196
+ # Remove any requested plugins, then add any requested plugins.
197
+ config.plugins_active.subtract(config.plugins_disabled)
198
+ config.plugins_active.merge(config.plugins_enabled)
199
+ Immunio.logger.info "Active plugins: #{config.plugins_active.to_a}"
200
+
201
+ end
202
+
203
+ def plugin_enabled?(plugin)
204
+ # Check if the specified `plugin` is enabled based on the Agent config.
205
+ config.plugins_active.member?(plugin)
206
+ end
207
+
208
+ def new_request(*args)
209
+ @processor.new_request(*args)
210
+ end
211
+
212
+ def finish_request(*args)
213
+ @processor.finish_request(*args)
214
+ end
215
+
216
+ def run_hook(*args)
217
+ @processor.run_hook(*args) if defined? @processor
218
+ end
219
+
220
+ def run_hook!(*args)
221
+ @processor.run_hook!(*args) if defined? @processor
222
+ end
223
+
224
+ def environment=(environment)
225
+ @processor.environment = environment
226
+ end
227
+ end
228
+
229
+ AGENT_INIT_MUTEX = Mutex.new
230
+ def self.agent
231
+ return @agent if @agent
232
+
233
+ AGENT_INIT_MUTEX.synchronize do
234
+ @agent = Agent.new
235
+ activate_plugins! if @agent.agent_enabled
236
+ end
237
+
238
+ @agent
239
+ end
240
+
241
+ def self.new_request(*args)
242
+ agent.new_request(*args)
243
+ end
244
+
245
+ def self.finish_request(*args)
246
+ agent.finish_request(*args)
247
+ end
248
+
249
+ def self.run_hook(*args)
250
+ agent.run_hook(*args)
251
+ end
252
+
253
+ def self.run_hook!(*args)
254
+ # Don't run hooks if we're starting up the agent and opening a log
255
+ agent.run_hook!(*args) unless !@agent && args[0] == "io" && args[1] == "open"
256
+ end
257
+
258
+ # Initialize startup logger now!
259
+ create_startup_logger
260
+ end