tainted_love 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (203) hide show
  1. checksums.yaml +7 -0
  2. data/.github/probots.yml +2 -0
  3. data/.gitignore +12 -0
  4. data/.rspec +3 -0
  5. data/.rubocop.yml +1188 -0
  6. data/.ruby-version +1 -0
  7. data/.travis.yml +7 -0
  8. data/CODE_OF_CONDUCT.md +73 -0
  9. data/Gemfile +8 -0
  10. data/Gemfile.lock +57 -0
  11. data/LICENSE.txt +21 -0
  12. data/README.md +85 -0
  13. data/Rakefile +8 -0
  14. data/bin/console +15 -0
  15. data/bin/setup +10 -0
  16. data/bin/test +7 -0
  17. data/dev.yml +28 -0
  18. data/docs/TaintedLove.html +482 -0
  19. data/docs/TaintedLove/Configuration.html +499 -0
  20. data/docs/TaintedLove/Replacer.html +129 -0
  21. data/docs/TaintedLove/Replacer/ActionViewHelpersMod.html +230 -0
  22. data/docs/TaintedLove/Replacer/Base.html +320 -0
  23. data/docs/TaintedLove/Replacer/HelperMod.html +226 -0
  24. data/docs/TaintedLove/Replacer/HelpersMod.html +230 -0
  25. data/docs/TaintedLove/Replacer/MarshalMod.html +178 -0
  26. data/docs/TaintedLove/Replacer/ObjectMod.html +282 -0
  27. data/docs/TaintedLove/Replacer/ReplaceActionController.html +329 -0
  28. data/docs/TaintedLove/Replacer/ReplaceActionView.html +317 -0
  29. data/docs/TaintedLove/Replacer/ReplaceActiveRecord.html +341 -0
  30. data/docs/TaintedLove/Replacer/ReplaceDigest.html +369 -0
  31. data/docs/TaintedLove/Replacer/ReplaceFile.html +245 -0
  32. data/docs/TaintedLove/Replacer/ReplaceKernel.html +211 -0
  33. data/docs/TaintedLove/Replacer/ReplaceMarshal.html +219 -0
  34. data/docs/TaintedLove/Replacer/ReplaceObject.html +231 -0
  35. data/docs/TaintedLove/Replacer/ReplaceRailsUserInput.html +374 -0
  36. data/docs/TaintedLove/Replacer/ReplaceSprokets.html +297 -0
  37. data/docs/TaintedLove/Replacer/SprocketsHelperMod.html +226 -0
  38. data/docs/TaintedLove/Reporter.html +117 -0
  39. data/docs/TaintedLove/Reporter/Base.html +466 -0
  40. data/docs/TaintedLove/Reporter/RackReporter.html +309 -0
  41. data/docs/TaintedLove/Reporter/SinatraReporter.html +402 -0
  42. data/docs/TaintedLove/Reporter/SinatraReporter/App.html +210 -0
  43. data/docs/TaintedLove/Reporter/StdoutReporter.html +305 -0
  44. data/docs/TaintedLove/SinatraReporter.html +387 -0
  45. data/docs/TaintedLove/SinatraReporter/App.html +210 -0
  46. data/docs/TaintedLove/StackTrace.html +650 -0
  47. data/docs/TaintedLove/Utils.html +550 -0
  48. data/docs/TaintedLove/Validator.html +129 -0
  49. data/docs/TaintedLove/Validator/ActionViewObjectSend.html +233 -0
  50. data/docs/TaintedLove/Validator/Base.html +200 -0
  51. data/docs/TaintedLove/Validator/ErbEval.html +229 -0
  52. data/docs/TaintedLove/Validator/RedisStoreSerialization.html +238 -0
  53. data/docs/TaintedLove/Validator/SproketsMarshal.html +233 -0
  54. data/docs/TaintedLove/Warning.html +665 -0
  55. data/docs/_index.html +371 -0
  56. data/docs/class_list.html +51 -0
  57. data/docs/css/common.css +1 -0
  58. data/docs/css/full_list.css +58 -0
  59. data/docs/css/style.css +496 -0
  60. data/docs/file.README.html +134 -0
  61. data/docs/file_list.html +56 -0
  62. data/docs/frames.html +17 -0
  63. data/docs/index.html +134 -0
  64. data/docs/js/app.js +292 -0
  65. data/docs/js/full_list.js +216 -0
  66. data/docs/js/jquery.js +4 -0
  67. data/docs/method_list.html +523 -0
  68. data/docs/top-level-namespace.html +110 -0
  69. data/example/.gitignore +31 -0
  70. data/example/.ruby-version +1 -0
  71. data/example/Gemfile +67 -0
  72. data/example/Gemfile.lock +226 -0
  73. data/example/README.md +24 -0
  74. data/example/Rakefile +8 -0
  75. data/example/app/assets/config/manifest.js +3 -0
  76. data/example/app/assets/images/.keep +0 -0
  77. data/example/app/assets/javascripts/application.js +16 -0
  78. data/example/app/assets/javascripts/cable.js +13 -0
  79. data/example/app/assets/javascripts/channels/.keep +0 -0
  80. data/example/app/assets/javascripts/products.coffee +3 -0
  81. data/example/app/assets/stylesheets/application.css +15 -0
  82. data/example/app/assets/stylesheets/products.scss +3 -0
  83. data/example/app/assets/stylesheets/scaffolds.scss +84 -0
  84. data/example/app/channels/application_cable/channel.rb +6 -0
  85. data/example/app/channels/application_cable/connection.rb +6 -0
  86. data/example/app/controllers/application_controller.rb +4 -0
  87. data/example/app/controllers/concerns/.keep +0 -0
  88. data/example/app/controllers/products_controller.rb +77 -0
  89. data/example/app/controllers/test_cases_controller.rb +20 -0
  90. data/example/app/helpers/application_helper.rb +4 -0
  91. data/example/app/helpers/products_helper.rb +4 -0
  92. data/example/app/helpers/test_cases_helper.rb +4 -0
  93. data/example/app/jobs/application_job.rb +4 -0
  94. data/example/app/mailers/application_mailer.rb +6 -0
  95. data/example/app/models/application_record.rb +5 -0
  96. data/example/app/models/concerns/.keep +0 -0
  97. data/example/app/models/product.rb +4 -0
  98. data/example/app/views/layouts/application.html.erb +15 -0
  99. data/example/app/views/layouts/mailer.html.erb +13 -0
  100. data/example/app/views/layouts/mailer.text.erb +1 -0
  101. data/example/app/views/products/_form.html.erb +32 -0
  102. data/example/app/views/products/_product.json.jbuilder +4 -0
  103. data/example/app/views/products/edit.html.erb +6 -0
  104. data/example/app/views/products/index.html.erb +31 -0
  105. data/example/app/views/products/index.json.jbuilder +3 -0
  106. data/example/app/views/products/new.html.erb +5 -0
  107. data/example/app/views/products/show.html.erb +19 -0
  108. data/example/app/views/products/show.json.jbuilder +3 -0
  109. data/example/app/views/test_cases/xss.html.erb +10 -0
  110. data/example/bin/bundle +5 -0
  111. data/example/bin/rails +11 -0
  112. data/example/bin/rake +11 -0
  113. data/example/bin/setup +38 -0
  114. data/example/bin/spring +18 -0
  115. data/example/bin/update +33 -0
  116. data/example/bin/yarn +11 -0
  117. data/example/config.ru +7 -0
  118. data/example/config/application.rb +21 -0
  119. data/example/config/boot.rb +6 -0
  120. data/example/config/cable.yml +10 -0
  121. data/example/config/credentials.yml.enc +1 -0
  122. data/example/config/database.yml +25 -0
  123. data/example/config/environment.rb +7 -0
  124. data/example/config/environments/development.rb +63 -0
  125. data/example/config/environments/production.rb +96 -0
  126. data/example/config/environments/test.rb +48 -0
  127. data/example/config/initializers/application_controller_renderer.rb +10 -0
  128. data/example/config/initializers/assets.rb +16 -0
  129. data/example/config/initializers/backtrace_silencers.rb +9 -0
  130. data/example/config/initializers/content_security_policy.rb +27 -0
  131. data/example/config/initializers/cookies_serializer.rb +7 -0
  132. data/example/config/initializers/filter_parameter_logging.rb +6 -0
  133. data/example/config/initializers/inflections.rb +18 -0
  134. data/example/config/initializers/mime_types.rb +6 -0
  135. data/example/config/initializers/tainted_love.rb +7 -0
  136. data/example/config/initializers/wrap_parameters.rb +16 -0
  137. data/example/config/locales/en.yml +33 -0
  138. data/example/config/puma.rb +36 -0
  139. data/example/config/routes.rb +10 -0
  140. data/example/config/spring.rb +8 -0
  141. data/example/config/storage.yml +34 -0
  142. data/example/db/migrate/20190311220346_create_products.rb +13 -0
  143. data/example/db/schema.rb +23 -0
  144. data/example/db/seeds.rb +9 -0
  145. data/example/lib/assets/.keep +0 -0
  146. data/example/lib/tasks/.keep +0 -0
  147. data/example/log/.keep +0 -0
  148. data/example/package.json +5 -0
  149. data/example/public/404.html +67 -0
  150. data/example/public/422.html +67 -0
  151. data/example/public/500.html +66 -0
  152. data/example/public/apple-touch-icon-precomposed.png +0 -0
  153. data/example/public/apple-touch-icon.png +0 -0
  154. data/example/public/favicon.ico +0 -0
  155. data/example/public/robots.txt +1 -0
  156. data/example/storage/.keep +0 -0
  157. data/example/test/application_system_test_case.rb +7 -0
  158. data/example/test/controllers/.keep +0 -0
  159. data/example/test/controllers/products_controller_test.rb +66 -0
  160. data/example/test/controllers/test_cases_controller_test.rb +39 -0
  161. data/example/test/fixtures/.keep +0 -0
  162. data/example/test/fixtures/files/.keep +0 -0
  163. data/example/test/fixtures/products.yml +11 -0
  164. data/example/test/helpers/.keep +0 -0
  165. data/example/test/integration/.keep +0 -0
  166. data/example/test/mailers/.keep +0 -0
  167. data/example/test/models/.keep +0 -0
  168. data/example/test/models/product_test.rb +9 -0
  169. data/example/test/replacers/replace_active_record_test.rb +31 -0
  170. data/example/test/replacers/replace_sprokets_test.rb +8 -0
  171. data/example/test/system/.keep +0 -0
  172. data/example/test/system/products_test.rb +49 -0
  173. data/example/test/test_helper.rb +37 -0
  174. data/example/tmp/.keep +0 -0
  175. data/example/vendor/.keep +0 -0
  176. data/lib/tainted_love.rb +57 -0
  177. data/lib/tainted_love/configuration.rb +16 -0
  178. data/lib/tainted_love/replacer/base.rb +25 -0
  179. data/lib/tainted_love/replacer/replace_action_controller.rb +61 -0
  180. data/lib/tainted_love/replacer/replace_action_view.rb +39 -0
  181. data/lib/tainted_love/replacer/replace_active_record.rb +47 -0
  182. data/lib/tainted_love/replacer/replace_digest.rb +39 -0
  183. data/lib/tainted_love/replacer/replace_file.rb +32 -0
  184. data/lib/tainted_love/replacer/replace_kernel.rb +44 -0
  185. data/lib/tainted_love/replacer/replace_marshal.rb +19 -0
  186. data/lib/tainted_love/replacer/replace_object.rb +30 -0
  187. data/lib/tainted_love/replacer/replace_rails_user_input.rb +59 -0
  188. data/lib/tainted_love/replacer/replace_sprokets.rb +25 -0
  189. data/lib/tainted_love/replacer/replace_yaml.rb +28 -0
  190. data/lib/tainted_love/reporter/base.rb +47 -0
  191. data/lib/tainted_love/reporter/file_reporter.rb +28 -0
  192. data/lib/tainted_love/reporter/stdout_reporter.rb +30 -0
  193. data/lib/tainted_love/stack_trace.rb +46 -0
  194. data/lib/tainted_love/utils.rb +80 -0
  195. data/lib/tainted_love/validator/action_view_object_send.rb +15 -0
  196. data/lib/tainted_love/validator/base.rb +16 -0
  197. data/lib/tainted_love/validator/erb_eval.rb +13 -0
  198. data/lib/tainted_love/validator/redis_store_serialization.rb +13 -0
  199. data/lib/tainted_love/validator/sprokets_marshal.rb +15 -0
  200. data/lib/tainted_love/version.rb +5 -0
  201. data/lib/tainted_love/warning.rb +30 -0
  202. data/tainted_love.gemspec +31 -0
  203. metadata +315 -0
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.5.3
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.3
7
+ before_install: gem install bundler -v 1.17.3
@@ -0,0 +1,73 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at opensource@shopify.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct/
72
+
73
+ [homepage]: https://www.contributor-covenant.org
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in tainted_love.gemspec
8
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,57 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ tainted_love (0.1.3)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.0)
10
+ diff-lcs (1.3)
11
+ jaro_winkler (1.5.2)
12
+ parallel (1.14.0)
13
+ parser (2.6.0.0)
14
+ ast (~> 2.4.0)
15
+ powerpack (0.1.2)
16
+ psych (3.1.0)
17
+ rainbow (3.0.0)
18
+ rake (10.5.0)
19
+ rspec (3.8.0)
20
+ rspec-core (~> 3.8.0)
21
+ rspec-expectations (~> 3.8.0)
22
+ rspec-mocks (~> 3.8.0)
23
+ rspec-core (3.8.0)
24
+ rspec-support (~> 3.8.0)
25
+ rspec-expectations (3.8.2)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.8.0)
28
+ rspec-mocks (3.8.0)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.8.0)
31
+ rspec-support (3.8.0)
32
+ rubocop (0.65.0)
33
+ jaro_winkler (~> 1.5.1)
34
+ parallel (~> 1.10)
35
+ parser (>= 2.5, != 2.5.1.1)
36
+ powerpack (~> 0.1)
37
+ psych (>= 3.1.0)
38
+ rainbow (>= 2.2.2, < 4.0)
39
+ ruby-progressbar (~> 1.7)
40
+ unicode-display_width (~> 1.4.0)
41
+ ruby-progressbar (1.10.0)
42
+ unicode-display_width (1.4.1)
43
+ yard (0.9.18)
44
+
45
+ PLATFORMS
46
+ ruby
47
+
48
+ DEPENDENCIES
49
+ bundler (~> 1.17)
50
+ rake (~> 10.0)
51
+ rspec (~> 3.0)
52
+ rubocop (~> 0.65.0)
53
+ tainted_love!
54
+ yard (~> 0.9.18)
55
+
56
+ BUNDLED WITH
57
+ 1.17.3
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Shopify
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,85 @@
1
+ # TaintedLove
2
+
3
+ TaintedLove is a dynamic security analysis tool for Ruby. It leverages Ruby's object tainting and monkey patching features to identify vulnerable code paths at runtime.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'tainted_love'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install tainted_love
20
+
21
+
22
+ ## Usage
23
+
24
+ TaintedLove needs to replace multiple functions. It is ideal to enable it when the application has all of its dependencies loaded and is ready to use.
25
+
26
+ To enable TaintedLove in your project:
27
+
28
+ ```ruby
29
+ TaintedLove.enable! do |config|
30
+ # This is the default configuration
31
+ # config.logger = Logger.new
32
+ # config.replacers = TaintedLove::Replacer::Base.replacers
33
+ # config.validators = TaintedLove::Validator::Base.validators
34
+ # config.reporter = TaintedLove::Reporter::StdoutReporter.new
35
+ end
36
+ ```
37
+
38
+ In Ruby on Rails, this could be done in an initializer file `config/initializer/tainted_love.rb`
39
+
40
+ ```ruby
41
+ TaintedLove.enable! do |config|
42
+ config.logger = Rails.logger
43
+ end
44
+ ```
45
+
46
+ Start your application! The default reporter will output into the console.
47
+
48
+ ## Detected Patterns
49
+ TaintedLove currently detects the following patterns. If the execution of the application ever encounters these function calls, TaintedLove will report it.
50
+
51
+ ```ruby
52
+ Object#send(tainted_input_1, tainted_input_2)
53
+ File.read(tainted_input).taint
54
+ File.write(tainted_input, _)
55
+ Kernel#eval(tainted_input)
56
+ Kernel#system(tainted_input)
57
+ Kernel#`(tainted_input)
58
+ Kernel#open("|" + tainted_input)
59
+ Marshal.load(tainted_input)
60
+ YAML.load(tainted_input)
61
+
62
+ # Rails specific patterns
63
+ render(tainted_input)
64
+ render(inline: tainted_input)
65
+ render(file: tainted_input)
66
+ <%= tainted_input.html_safe %>
67
+ Model.where(tainted_input)
68
+ Model.select(tainted_input)
69
+ Model.find_by_sql(tainted_input)
70
+ Model.count_by_sql(tainted_input)
71
+ ```
72
+
73
+ ## Development
74
+
75
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
76
+
77
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
78
+
79
+ ## Contributing
80
+
81
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Shopify/tainted_love.
82
+
83
+ ## License
84
+
85
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task(default: :spec)
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'tainted_love'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ cd example
9
+
10
+ bundle install
data/bin/test ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ bundle exec rake
6
+ cd example
7
+ rails test
data/dev.yml ADDED
@@ -0,0 +1,28 @@
1
+ name: tainted-love
2
+
3
+ type: ruby
4
+
5
+ up:
6
+ - homebrew:
7
+ - openssl
8
+ - ruby: 2.5.3
9
+ - bundler
10
+ - bundler:
11
+ gemfile: example/Gemfile
12
+
13
+ commands:
14
+ console:
15
+ desc: 'start a console'
16
+ run: bin/console
17
+
18
+ test:
19
+ desc: 'run the tests'
20
+ run: bin/test
21
+
22
+ docs:
23
+ desc: 'generate the documentation'
24
+ run: bundle exec yard -o docs
25
+
26
+ style:
27
+ desc: 'run rubocop'
28
+ run: bundle exec rubocop
@@ -0,0 +1,482 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Module: TaintedLove
8
+
9
+ &mdash; Documentation by YARD 0.9.18
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "TaintedLove";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index (T)</a> &raquo;
40
+
41
+
42
+ <span class="title">TaintedLove</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Module: TaintedLove
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+ <dl>
73
+ <dt>Extended by:</dt>
74
+ <dd><span class='object_link'><a href="TaintedLove/Utils.html" title="TaintedLove::Utils (module)">Utils</a></span></dd>
75
+ </dl>
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+ <dl>
85
+ <dt>Defined in:</dt>
86
+ <dd>lib/tainted_love.rb<span class="defines">,<br />
87
+ lib/tainted_love/utils.rb,<br /> lib/tainted_love/version.rb,<br /> lib/tainted_love/warning.rb,<br /> lib/tainted_love/stack_trace.rb,<br /> lib/tainted_love/configuration.rb,<br /> lib/tainted_love/replacer/base.rb,<br /> lib/tainted_love/reporter/base.rb,<br /> lib/tainted_love/validator/base.rb,<br /> lib/tainted_love/validator/erb_eval.rb,<br /> lib/tainted_love/replacer/replace_file.rb,<br /> lib/tainted_love/replacer/replace_digest.rb,<br /> lib/tainted_love/replacer/replace_kernel.rb,<br /> lib/tainted_love/replacer/replace_object.rb,<br /> lib/tainted_love/replacer/replace_marshal.rb,<br /> lib/tainted_love/reporter/stdout_reporter.rb,<br /> lib/tainted_love/replacer/replace_sprokets.rb,<br /> lib/tainted_love/reporter/sinatra_reporter.rb,<br /> lib/tainted_love/validator/sprokets_marshal.rb,<br /> lib/tainted_love/replacer/replace_action_view.rb,<br /> lib/tainted_love/replacer/replace_active_record.rb,<br /> lib/tainted_love/replacer/replace_rails_user_input.rb,<br /> lib/tainted_love/validator/action_view_object_send.rb,<br /> lib/tainted_love/replacer/replace_action_controller.rb,<br /> lib/tainted_love/validator/redis_store_serialization.rb</span>
88
+ </dd>
89
+ </dl>
90
+
91
+ </div>
92
+
93
+ <h2>Defined Under Namespace</h2>
94
+ <p class="children">
95
+
96
+
97
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="TaintedLove/Replacer.html" title="TaintedLove::Replacer (module)">Replacer</a></span>, <span class='object_link'><a href="TaintedLove/Reporter.html" title="TaintedLove::Reporter (module)">Reporter</a></span>, <span class='object_link'><a href="TaintedLove/Utils.html" title="TaintedLove::Utils (module)">Utils</a></span>, <span class='object_link'><a href="TaintedLove/Validator.html" title="TaintedLove::Validator (module)">Validator</a></span>
98
+
99
+
100
+
101
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="TaintedLove/Configuration.html" title="TaintedLove::Configuration (class)">Configuration</a></span>, <span class='object_link'><a href="TaintedLove/StackTrace.html" title="TaintedLove::StackTrace (class)">StackTrace</a></span>, <span class='object_link'><a href="TaintedLove/Warning.html" title="TaintedLove::Warning (class)">Warning</a></span>
102
+
103
+
104
+ </p>
105
+
106
+
107
+ <h2>
108
+ Constant Summary
109
+ <small><a href="#" class="constants_summary_toggle">collapse</a></small>
110
+ </h2>
111
+
112
+ <dl class="constants">
113
+
114
+ <dt id="VERSION-constant" class="">VERSION =
115
+
116
+ </dt>
117
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>0.1.3</span><span class='tstring_end'>&#39;</span></span></pre></dd>
118
+
119
+ </dl>
120
+
121
+
122
+
123
+
124
+
125
+ <h2>Class Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
126
+ <ul class="summary">
127
+
128
+ <li class="public ">
129
+ <span class="summary_signature">
130
+
131
+ <a href="#configuration-class_method" title="configuration (class method)">.<strong>configuration</strong> &#x21d2; Object </a>
132
+
133
+
134
+
135
+ </span>
136
+
137
+
138
+
139
+
140
+ <span class="note title readonly">readonly</span>
141
+
142
+
143
+
144
+
145
+
146
+
147
+
148
+
149
+
150
+ <span class="summary_desc"><div class='inline'>
151
+ <p>Returns the value of attribute configuration.</p>
152
+ </div></span>
153
+
154
+ </li>
155
+
156
+
157
+ </ul>
158
+
159
+
160
+
161
+
162
+
163
+ <h2>
164
+ Class Method Summary
165
+ <small><a href="#" class="summary_toggle">collapse</a></small>
166
+ </h2>
167
+
168
+ <ul class="summary">
169
+
170
+ <li class="public ">
171
+ <span class="summary_signature">
172
+
173
+ <a href="#enable!-class_method" title="enable! (class method)">.<strong>enable!</strong> {|TaintedLove::Configuration| ... } &#x21d2; Object </a>
174
+
175
+
176
+
177
+ </span>
178
+
179
+
180
+
181
+
182
+
183
+
184
+
185
+
186
+
187
+ <span class="summary_desc"><div class='inline'>
188
+ <p>Enables TaintedLove.</p>
189
+ </div></span>
190
+
191
+ </li>
192
+
193
+
194
+ <li class="public ">
195
+ <span class="summary_signature">
196
+
197
+ <a href="#report-class_method" title="report (class method)">.<strong>report</strong>(replacer, tainted_input) &#x21d2; Object </a>
198
+
199
+
200
+
201
+ </span>
202
+
203
+
204
+
205
+
206
+
207
+
208
+
209
+
210
+
211
+ <span class="summary_desc"><div class='inline'>
212
+ <p>Report tainted input.</p>
213
+ </div></span>
214
+
215
+ </li>
216
+
217
+
218
+ </ul>
219
+
220
+
221
+
222
+
223
+
224
+
225
+
226
+
227
+
228
+
229
+
230
+ <h3 class="inherited">Methods included from <span class='object_link'><a href="TaintedLove/Utils.html" title="TaintedLove::Utils (module)">Utils</a></span></h3>
231
+ <p class="inherited"><span class='object_link'><a href="TaintedLove/Utils.html#add_tracking-instance_method" title="TaintedLove::Utils#add_tracking (method)">add_tracking</a></span>, <span class='object_link'><a href="TaintedLove/Utils.html#hash-instance_method" title="TaintedLove::Utils#hash (method)">hash</a></span>, <span class='object_link'><a href="TaintedLove/Utils.html#proxy_method-instance_method" title="TaintedLove::Utils#proxy_method (method)">proxy_method</a></span></p>
232
+
233
+ <div id="class_attr_details" class="attr_details">
234
+ <h2>Class Attribute Details</h2>
235
+
236
+
237
+ <span id=""></span>
238
+ <div class="method_details first">
239
+ <h3 class="signature first" id="configuration-class_method">
240
+
241
+ .<strong>configuration</strong> &#x21d2; <tt>Object</tt> <span class="extras">(readonly)</span>
242
+
243
+
244
+
245
+
246
+
247
+ </h3><div class="docstring">
248
+ <div class="discussion">
249
+
250
+ <p>Returns the value of attribute configuration</p>
251
+
252
+
253
+ </div>
254
+ </div>
255
+ <div class="tags">
256
+
257
+
258
+ </div><table class="source_code">
259
+ <tr>
260
+ <td>
261
+ <pre class="lines">
262
+
263
+
264
+ 9
265
+ 10
266
+ 11</pre>
267
+ </td>
268
+ <td>
269
+ <pre class="code"><span class="info file"># File 'lib/tainted_love.rb', line 9</span>
270
+
271
+ <span class='kw'>def</span> <span class='id identifier rubyid_configuration'>configuration</span>
272
+ <span class='ivar'>@configuration</span>
273
+ <span class='kw'>end</span></pre>
274
+ </td>
275
+ </tr>
276
+ </table>
277
+ </div>
278
+
279
+ </div>
280
+
281
+
282
+ <div id="class_method_details" class="method_details_list">
283
+ <h2>Class Method Details</h2>
284
+
285
+
286
+ <div class="method_details first">
287
+ <h3 class="signature first" id="enable!-class_method">
288
+
289
+ .<strong>enable!</strong> {|TaintedLove::Configuration| ... } &#x21d2; <tt>Object</tt>
290
+
291
+
292
+
293
+
294
+
295
+ </h3><div class="docstring">
296
+ <div class="discussion">
297
+
298
+ <p>Enables TaintedLove. Use a block to configure the
299
+ TaintedLove::Configuration</p>
300
+
301
+
302
+ </div>
303
+ </div>
304
+ <div class="tags">
305
+
306
+ <p class="tag_title">Yields:</p>
307
+ <ul class="yield">
308
+
309
+ <li>
310
+
311
+
312
+ <span class='type'>(<tt><span class='object_link'><a href="TaintedLove/Configuration.html" title="TaintedLove::Configuration (class)">TaintedLove::Configuration</a></span></tt>)</span>
313
+
314
+
315
+
316
+ </li>
317
+
318
+ </ul>
319
+
320
+ </div><table class="source_code">
321
+ <tr>
322
+ <td>
323
+ <pre class="lines">
324
+
325
+
326
+ 15
327
+ 16
328
+ 17
329
+ 18
330
+ 19
331
+ 20
332
+ 21
333
+ 22
334
+ 23
335
+ 24
336
+ 25
337
+ 26
338
+ 27
339
+ 28
340
+ 29
341
+ 30
342
+ 31
343
+ 32
344
+ 33
345
+ 34</pre>
346
+ </td>
347
+ <td>
348
+ <pre class="code"><span class="info file"># File 'lib/tainted_love.rb', line 15</span>
349
+
350
+ <span class='kw'>def</span> <span class='id identifier rubyid_enable!'>enable!</span>
351
+ <span class='id identifier rubyid_configuration'>configuration</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="" title="TaintedLove (module)">TaintedLove</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="TaintedLove/Configuration.html" title="TaintedLove::Configuration (class)">Configuration</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="TaintedLove/Configuration.html#initialize-instance_method" title="TaintedLove::Configuration#initialize (method)">new</a></span></span>
352
+
353
+ <span class='id identifier rubyid_configuration'>configuration</span><span class='period'>.</span><span class='id identifier rubyid_logger'>logger</span><span class='period'>.</span><span class='id identifier rubyid_info'>info</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>TaintedLove is enabled</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
354
+ <span class='id identifier rubyid_configuration'>configuration</span><span class='period'>.</span><span class='id identifier rubyid_replacers'>replacers</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="" title="TaintedLove (module)">TaintedLove</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="TaintedLove/Replacer.html" title="TaintedLove::Replacer (module)">Replacer</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="TaintedLove/Replacer/Base.html" title="TaintedLove::Replacer::Base (class)">Base</a></span></span><span class='period'>.</span><span class='id identifier rubyid_replacers'><span class='object_link'><a href="TaintedLove/Replacer/Base.html#replacers-class_method" title="TaintedLove::Replacer::Base.replacers (method)">replacers</a></span></span>
355
+ <span class='id identifier rubyid_configuration'>configuration</span><span class='period'>.</span><span class='id identifier rubyid_validators'>validators</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="" title="TaintedLove (module)">TaintedLove</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="TaintedLove/Validator.html" title="TaintedLove::Validator (module)">Validator</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="TaintedLove/Validator/Base.html" title="TaintedLove::Validator::Base (class)">Base</a></span></span><span class='period'>.</span><span class='id identifier rubyid_validators'><span class='object_link'><a href="TaintedLove/Validator/Base.html#validators-class_method" title="TaintedLove::Validator::Base.validators (method)">validators</a></span></span>
356
+ <span class='id identifier rubyid_configuration'>configuration</span><span class='period'>.</span><span class='id identifier rubyid_reporter'>reporter</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="" title="TaintedLove (module)">TaintedLove</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="TaintedLove/Reporter.html" title="TaintedLove::Reporter (module)">Reporter</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="TaintedLove/Reporter/StdoutReporter.html" title="TaintedLove::Reporter::StdoutReporter (class)">StdoutReporter</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="TaintedLove/Reporter/Base.html#initialize-instance_method" title="TaintedLove::Reporter::Base#initialize (method)">new</a></span></span>
357
+
358
+ <span class='comment'># Allows customization of which replacers/validators should be used
359
+ </span> <span class='kw'>yield</span> <span class='id identifier rubyid_configuration'>configuration</span> <span class='kw'>if</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
360
+
361
+ <span class='ivar'>@configuration</span> <span class='op'>=</span> <span class='id identifier rubyid_configuration'>configuration</span>
362
+
363
+ <span class='id identifier rubyid_configuration'>configuration</span><span class='period'>.</span><span class='id identifier rubyid_replacers'>replacers</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_replacer'>replacer</span><span class='op'>|</span>
364
+ <span class='id identifier rubyid_replacer'>replacer</span> <span class='op'>=</span> <span class='id identifier rubyid_replacer'>replacer</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
365
+ <span class='id identifier rubyid_replacer'>replacer</span><span class='period'>.</span><span class='id identifier rubyid_replace!'>replace!</span> <span class='kw'>if</span> <span class='id identifier rubyid_replacer'>replacer</span><span class='period'>.</span><span class='id identifier rubyid_should_replace?'>should_replace?</span>
366
+ <span class='kw'>end</span>
367
+
368
+ <span class='id identifier rubyid_configuration'>configuration</span>
369
+ <span class='kw'>end</span></pre>
370
+ </td>
371
+ </tr>
372
+ </table>
373
+ </div>
374
+
375
+ <div class="method_details ">
376
+ <h3 class="signature " id="report-class_method">
377
+
378
+ .<strong>report</strong>(replacer, tainted_input) &#x21d2; <tt>Object</tt>
379
+
380
+
381
+
382
+
383
+
384
+ </h3><div class="docstring">
385
+ <div class="discussion">
386
+
387
+ <p>Report tainted input</p>
388
+
389
+
390
+ </div>
391
+ </div>
392
+ <div class="tags">
393
+ <p class="tag_title">Parameters:</p>
394
+ <ul class="param">
395
+
396
+ <li>
397
+
398
+ <span class='name'>replacer</span>
399
+
400
+
401
+ <span class='type'>(<tt>Symbol</tt>)</span>
402
+
403
+
404
+
405
+ &mdash;
406
+ <div class='inline'>
407
+ <p>Replacer reporting the issue</p>
408
+ </div>
409
+
410
+ </li>
411
+
412
+ <li>
413
+
414
+ <span class='name'>tainted_input</span>
415
+
416
+
417
+ <span class='type'>(<tt>Object</tt>)</span>
418
+
419
+
420
+
421
+ &mdash;
422
+ <div class='inline'>
423
+ <p>Tainted object</p>
424
+ </div>
425
+
426
+ </li>
427
+
428
+ </ul>
429
+
430
+
431
+ </div><table class="source_code">
432
+ <tr>
433
+ <td>
434
+ <pre class="lines">
435
+
436
+
437
+ 40
438
+ 41
439
+ 42
440
+ 43
441
+ 44
442
+ 45
443
+ 46
444
+ 47
445
+ 48
446
+ 49
447
+ 50
448
+ 51</pre>
449
+ </td>
450
+ <td>
451
+ <pre class="code"><span class="info file"># File 'lib/tainted_love.rb', line 40</span>
452
+
453
+ <span class='kw'>def</span> <span class='id identifier rubyid_report'>report</span><span class='lparen'>(</span><span class='id identifier rubyid_replacer'>replacer</span><span class='comma'>,</span> <span class='id identifier rubyid_tainted_input'>tainted_input</span><span class='rparen'>)</span>
454
+ <span class='id identifier rubyid_warning'>warning</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="" title="TaintedLove (module)">TaintedLove</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="TaintedLove/Warning.html" title="TaintedLove::Warning (class)">Warning</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="TaintedLove/Warning.html#initialize-instance_method" title="TaintedLove::Warning#initialize (method)">new</a></span></span>
455
+ <span class='id identifier rubyid_warning'>warning</span><span class='period'>.</span><span class='id identifier rubyid_tainted_input'>tainted_input</span> <span class='op'>=</span> <span class='id identifier rubyid_tainted_input'>tainted_input</span>
456
+ <span class='id identifier rubyid_warning'>warning</span><span class='period'>.</span><span class='id identifier rubyid_stack_trace'>stack_trace</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="" title="TaintedLove (module)">TaintedLove</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="TaintedLove/StackTrace.html" title="TaintedLove::StackTrace (class)">StackTrace</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="TaintedLove/StackTrace.html#initialize-instance_method" title="TaintedLove::StackTrace#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='const'>Thread</span><span class='period'>.</span><span class='id identifier rubyid_current'>current</span><span class='period'>.</span><span class='id identifier rubyid_backtrace'>backtrace</span><span class='lparen'>(</span><span class='int'>3</span><span class='rparen'>)</span><span class='rparen'>)</span>
457
+ <span class='id identifier rubyid_warning'>warning</span><span class='period'>.</span><span class='id identifier rubyid_replacer'>replacer</span> <span class='op'>=</span> <span class='id identifier rubyid_replacer'>replacer</span>
458
+
459
+ <span class='id identifier rubyid_should_remove'>should_remove</span> <span class='op'>=</span> <span class='ivar'>@configuration</span><span class='period'>.</span><span class='id identifier rubyid_validators'>validators</span><span class='period'>.</span><span class='id identifier rubyid_any?'>any?</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_validator'>validator</span><span class='op'>|</span>
460
+ <span class='id identifier rubyid_validator'>validator</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='period'>.</span><span class='id identifier rubyid_remove?'>remove?</span><span class='lparen'>(</span><span class='id identifier rubyid_warning'>warning</span><span class='rparen'>)</span>
461
+ <span class='kw'>end</span>
462
+
463
+ <span class='ivar'>@configuration</span><span class='period'>.</span><span class='id identifier rubyid_reporter'>reporter</span><span class='period'>.</span><span class='id identifier rubyid_add_warning'>add_warning</span><span class='lparen'>(</span><span class='id identifier rubyid_warning'>warning</span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='id identifier rubyid_should_remove'>should_remove</span>
464
+ <span class='kw'>end</span></pre>
465
+ </td>
466
+ </tr>
467
+ </table>
468
+ </div>
469
+
470
+ </div>
471
+
472
+ </div>
473
+
474
+ <div id="footer">
475
+ Generated on Tue Apr 2 15:50:34 2019 by
476
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
477
+ 0.9.18 (ruby-2.5.3).
478
+ </div>
479
+
480
+ </div>
481
+ </body>
482
+ </html>