tainted_love 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/probots.yml +2 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.rubocop.yml +1188 -0
- data/.ruby-version +1 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +73 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +57 -0
- data/LICENSE.txt +21 -0
- data/README.md +85 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +10 -0
- data/bin/test +7 -0
- data/dev.yml +28 -0
- data/docs/TaintedLove.html +482 -0
- data/docs/TaintedLove/Configuration.html +499 -0
- data/docs/TaintedLove/Replacer.html +129 -0
- data/docs/TaintedLove/Replacer/ActionViewHelpersMod.html +230 -0
- data/docs/TaintedLove/Replacer/Base.html +320 -0
- data/docs/TaintedLove/Replacer/HelperMod.html +226 -0
- data/docs/TaintedLove/Replacer/HelpersMod.html +230 -0
- data/docs/TaintedLove/Replacer/MarshalMod.html +178 -0
- data/docs/TaintedLove/Replacer/ObjectMod.html +282 -0
- data/docs/TaintedLove/Replacer/ReplaceActionController.html +329 -0
- data/docs/TaintedLove/Replacer/ReplaceActionView.html +317 -0
- data/docs/TaintedLove/Replacer/ReplaceActiveRecord.html +341 -0
- data/docs/TaintedLove/Replacer/ReplaceDigest.html +369 -0
- data/docs/TaintedLove/Replacer/ReplaceFile.html +245 -0
- data/docs/TaintedLove/Replacer/ReplaceKernel.html +211 -0
- data/docs/TaintedLove/Replacer/ReplaceMarshal.html +219 -0
- data/docs/TaintedLove/Replacer/ReplaceObject.html +231 -0
- data/docs/TaintedLove/Replacer/ReplaceRailsUserInput.html +374 -0
- data/docs/TaintedLove/Replacer/ReplaceSprokets.html +297 -0
- data/docs/TaintedLove/Replacer/SprocketsHelperMod.html +226 -0
- data/docs/TaintedLove/Reporter.html +117 -0
- data/docs/TaintedLove/Reporter/Base.html +466 -0
- data/docs/TaintedLove/Reporter/RackReporter.html +309 -0
- data/docs/TaintedLove/Reporter/SinatraReporter.html +402 -0
- data/docs/TaintedLove/Reporter/SinatraReporter/App.html +210 -0
- data/docs/TaintedLove/Reporter/StdoutReporter.html +305 -0
- data/docs/TaintedLove/SinatraReporter.html +387 -0
- data/docs/TaintedLove/SinatraReporter/App.html +210 -0
- data/docs/TaintedLove/StackTrace.html +650 -0
- data/docs/TaintedLove/Utils.html +550 -0
- data/docs/TaintedLove/Validator.html +129 -0
- data/docs/TaintedLove/Validator/ActionViewObjectSend.html +233 -0
- data/docs/TaintedLove/Validator/Base.html +200 -0
- data/docs/TaintedLove/Validator/ErbEval.html +229 -0
- data/docs/TaintedLove/Validator/RedisStoreSerialization.html +238 -0
- data/docs/TaintedLove/Validator/SproketsMarshal.html +233 -0
- data/docs/TaintedLove/Warning.html +665 -0
- data/docs/_index.html +371 -0
- data/docs/class_list.html +51 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +496 -0
- data/docs/file.README.html +134 -0
- data/docs/file_list.html +56 -0
- data/docs/frames.html +17 -0
- data/docs/index.html +134 -0
- data/docs/js/app.js +292 -0
- data/docs/js/full_list.js +216 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +523 -0
- data/docs/top-level-namespace.html +110 -0
- data/example/.gitignore +31 -0
- data/example/.ruby-version +1 -0
- data/example/Gemfile +67 -0
- data/example/Gemfile.lock +226 -0
- data/example/README.md +24 -0
- data/example/Rakefile +8 -0
- data/example/app/assets/config/manifest.js +3 -0
- data/example/app/assets/images/.keep +0 -0
- data/example/app/assets/javascripts/application.js +16 -0
- data/example/app/assets/javascripts/cable.js +13 -0
- data/example/app/assets/javascripts/channels/.keep +0 -0
- data/example/app/assets/javascripts/products.coffee +3 -0
- data/example/app/assets/stylesheets/application.css +15 -0
- data/example/app/assets/stylesheets/products.scss +3 -0
- data/example/app/assets/stylesheets/scaffolds.scss +84 -0
- data/example/app/channels/application_cable/channel.rb +6 -0
- data/example/app/channels/application_cable/connection.rb +6 -0
- data/example/app/controllers/application_controller.rb +4 -0
- data/example/app/controllers/concerns/.keep +0 -0
- data/example/app/controllers/products_controller.rb +77 -0
- data/example/app/controllers/test_cases_controller.rb +20 -0
- data/example/app/helpers/application_helper.rb +4 -0
- data/example/app/helpers/products_helper.rb +4 -0
- data/example/app/helpers/test_cases_helper.rb +4 -0
- data/example/app/jobs/application_job.rb +4 -0
- data/example/app/mailers/application_mailer.rb +6 -0
- data/example/app/models/application_record.rb +5 -0
- data/example/app/models/concerns/.keep +0 -0
- data/example/app/models/product.rb +4 -0
- data/example/app/views/layouts/application.html.erb +15 -0
- data/example/app/views/layouts/mailer.html.erb +13 -0
- data/example/app/views/layouts/mailer.text.erb +1 -0
- data/example/app/views/products/_form.html.erb +32 -0
- data/example/app/views/products/_product.json.jbuilder +4 -0
- data/example/app/views/products/edit.html.erb +6 -0
- data/example/app/views/products/index.html.erb +31 -0
- data/example/app/views/products/index.json.jbuilder +3 -0
- data/example/app/views/products/new.html.erb +5 -0
- data/example/app/views/products/show.html.erb +19 -0
- data/example/app/views/products/show.json.jbuilder +3 -0
- data/example/app/views/test_cases/xss.html.erb +10 -0
- data/example/bin/bundle +5 -0
- data/example/bin/rails +11 -0
- data/example/bin/rake +11 -0
- data/example/bin/setup +38 -0
- data/example/bin/spring +18 -0
- data/example/bin/update +33 -0
- data/example/bin/yarn +11 -0
- data/example/config.ru +7 -0
- data/example/config/application.rb +21 -0
- data/example/config/boot.rb +6 -0
- data/example/config/cable.yml +10 -0
- data/example/config/credentials.yml.enc +1 -0
- data/example/config/database.yml +25 -0
- data/example/config/environment.rb +7 -0
- data/example/config/environments/development.rb +63 -0
- data/example/config/environments/production.rb +96 -0
- data/example/config/environments/test.rb +48 -0
- data/example/config/initializers/application_controller_renderer.rb +10 -0
- data/example/config/initializers/assets.rb +16 -0
- data/example/config/initializers/backtrace_silencers.rb +9 -0
- data/example/config/initializers/content_security_policy.rb +27 -0
- data/example/config/initializers/cookies_serializer.rb +7 -0
- data/example/config/initializers/filter_parameter_logging.rb +6 -0
- data/example/config/initializers/inflections.rb +18 -0
- data/example/config/initializers/mime_types.rb +6 -0
- data/example/config/initializers/tainted_love.rb +7 -0
- data/example/config/initializers/wrap_parameters.rb +16 -0
- data/example/config/locales/en.yml +33 -0
- data/example/config/puma.rb +36 -0
- data/example/config/routes.rb +10 -0
- data/example/config/spring.rb +8 -0
- data/example/config/storage.yml +34 -0
- data/example/db/migrate/20190311220346_create_products.rb +13 -0
- data/example/db/schema.rb +23 -0
- data/example/db/seeds.rb +9 -0
- data/example/lib/assets/.keep +0 -0
- data/example/lib/tasks/.keep +0 -0
- data/example/log/.keep +0 -0
- data/example/package.json +5 -0
- data/example/public/404.html +67 -0
- data/example/public/422.html +67 -0
- data/example/public/500.html +66 -0
- data/example/public/apple-touch-icon-precomposed.png +0 -0
- data/example/public/apple-touch-icon.png +0 -0
- data/example/public/favicon.ico +0 -0
- data/example/public/robots.txt +1 -0
- data/example/storage/.keep +0 -0
- data/example/test/application_system_test_case.rb +7 -0
- data/example/test/controllers/.keep +0 -0
- data/example/test/controllers/products_controller_test.rb +66 -0
- data/example/test/controllers/test_cases_controller_test.rb +39 -0
- data/example/test/fixtures/.keep +0 -0
- data/example/test/fixtures/files/.keep +0 -0
- data/example/test/fixtures/products.yml +11 -0
- data/example/test/helpers/.keep +0 -0
- data/example/test/integration/.keep +0 -0
- data/example/test/mailers/.keep +0 -0
- data/example/test/models/.keep +0 -0
- data/example/test/models/product_test.rb +9 -0
- data/example/test/replacers/replace_active_record_test.rb +31 -0
- data/example/test/replacers/replace_sprokets_test.rb +8 -0
- data/example/test/system/.keep +0 -0
- data/example/test/system/products_test.rb +49 -0
- data/example/test/test_helper.rb +37 -0
- data/example/tmp/.keep +0 -0
- data/example/vendor/.keep +0 -0
- data/lib/tainted_love.rb +57 -0
- data/lib/tainted_love/configuration.rb +16 -0
- data/lib/tainted_love/replacer/base.rb +25 -0
- data/lib/tainted_love/replacer/replace_action_controller.rb +61 -0
- data/lib/tainted_love/replacer/replace_action_view.rb +39 -0
- data/lib/tainted_love/replacer/replace_active_record.rb +47 -0
- data/lib/tainted_love/replacer/replace_digest.rb +39 -0
- data/lib/tainted_love/replacer/replace_file.rb +32 -0
- data/lib/tainted_love/replacer/replace_kernel.rb +44 -0
- data/lib/tainted_love/replacer/replace_marshal.rb +19 -0
- data/lib/tainted_love/replacer/replace_object.rb +30 -0
- data/lib/tainted_love/replacer/replace_rails_user_input.rb +59 -0
- data/lib/tainted_love/replacer/replace_sprokets.rb +25 -0
- data/lib/tainted_love/replacer/replace_yaml.rb +28 -0
- data/lib/tainted_love/reporter/base.rb +47 -0
- data/lib/tainted_love/reporter/file_reporter.rb +28 -0
- data/lib/tainted_love/reporter/stdout_reporter.rb +30 -0
- data/lib/tainted_love/stack_trace.rb +46 -0
- data/lib/tainted_love/utils.rb +80 -0
- data/lib/tainted_love/validator/action_view_object_send.rb +15 -0
- data/lib/tainted_love/validator/base.rb +16 -0
- data/lib/tainted_love/validator/erb_eval.rb +13 -0
- data/lib/tainted_love/validator/redis_store_serialization.rb +13 -0
- data/lib/tainted_love/validator/sprokets_marshal.rb +15 -0
- data/lib/tainted_love/version.rb +5 -0
- data/lib/tainted_love/warning.rb +30 -0
- data/tainted_love.gemspec +31 -0
- metadata +315 -0
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TaintedLove
|
4
|
+
module Replacer
|
5
|
+
class ReplaceSprokets < Base
|
6
|
+
def should_replace?
|
7
|
+
Object.const_defined?('Sprockets')
|
8
|
+
end
|
9
|
+
|
10
|
+
def replace!
|
11
|
+
mod = Module.new do
|
12
|
+
def javascript_include_tag(*sources)
|
13
|
+
super(*sources).untaint
|
14
|
+
end
|
15
|
+
|
16
|
+
def stylesheet_link_tag(*sources)
|
17
|
+
super(*sources).untaint
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
Sprockets::Rails::Helper.prepend(mod)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TaintedLove
|
4
|
+
module Replacer
|
5
|
+
class ReplaceYAML < Base
|
6
|
+
def should_replace?
|
7
|
+
Object.const_defined?('YAML')
|
8
|
+
end
|
9
|
+
|
10
|
+
def replace!
|
11
|
+
YAML.instance_eval do
|
12
|
+
alias :_tainted_love_original_load :load
|
13
|
+
|
14
|
+
def load(source, *args)
|
15
|
+
TaintedLove.report(
|
16
|
+
:ReplaceYAML,
|
17
|
+
source,
|
18
|
+
[:rce],
|
19
|
+
'YAML.load using tainted input'
|
20
|
+
) if source.tainted?
|
21
|
+
|
22
|
+
_tainted_love_original_load(source, *args)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'set'
|
4
|
+
|
5
|
+
module TaintedLove
|
6
|
+
module Reporter
|
7
|
+
# Base reporter
|
8
|
+
class Base
|
9
|
+
attr_reader :warnings
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@warnings = Hash.new do |h, k|
|
13
|
+
h[k] = {
|
14
|
+
stack_trace: nil,
|
15
|
+
replacer: nil,
|
16
|
+
inputs: {},
|
17
|
+
tags: [],
|
18
|
+
message: nil,
|
19
|
+
}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Stores a warning by its stack trace hash
|
24
|
+
#
|
25
|
+
# @param warning [TaintedLove::Warning]
|
26
|
+
def store_warning(warning)
|
27
|
+
key = warning.stack_trace.trace_hash
|
28
|
+
|
29
|
+
@warnings[key].merge!(
|
30
|
+
replacer: warning.replacer,
|
31
|
+
stack_trace: warning.stack_trace.lines,
|
32
|
+
tags: warning.tags,
|
33
|
+
message: warning.message,
|
34
|
+
)
|
35
|
+
|
36
|
+
@warnings[key][:inputs][warning.tainted_input] = warning.reported_at
|
37
|
+
end
|
38
|
+
|
39
|
+
# Adds a warning to the reporter
|
40
|
+
#
|
41
|
+
# @param warning [TaintedLove::Warning]
|
42
|
+
def add_warning(warning)
|
43
|
+
store_warning(warning)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module TaintedLove
|
6
|
+
module Reporter
|
7
|
+
# Reporter that outputs warnings into a JSON file
|
8
|
+
class FileReporter < Base
|
9
|
+
attr_reader :file_path
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
super
|
13
|
+
|
14
|
+
@file_path = '/tmp/tainted_love.json'
|
15
|
+
end
|
16
|
+
|
17
|
+
def add_warning(warning)
|
18
|
+
super(warning)
|
19
|
+
|
20
|
+
update_file
|
21
|
+
end
|
22
|
+
|
23
|
+
def update_file
|
24
|
+
File.write(@file_path, @warnings.to_json)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TaintedLove
|
4
|
+
module Reporter
|
5
|
+
# Reporter that outputs warnings in the console
|
6
|
+
class StdoutReporter < Base
|
7
|
+
def add_warning(warning)
|
8
|
+
puts ''
|
9
|
+
puts format_warning(warning)
|
10
|
+
puts ''
|
11
|
+
end
|
12
|
+
|
13
|
+
def format_warning(warning)
|
14
|
+
out = []
|
15
|
+
out << "[!] Tainted input found by #{warning.replacer}"
|
16
|
+
out << warning.stack_trace.trace_hash
|
17
|
+
|
18
|
+
out << if warning.tainted_input.size < 100
|
19
|
+
warning.tainted_input.inspect
|
20
|
+
else
|
21
|
+
warning.tainted_input.inspect[0..100] + '...'
|
22
|
+
end
|
23
|
+
|
24
|
+
out << warning.stack_trace.lines.take(5)
|
25
|
+
|
26
|
+
out.join("\n")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TaintedLove
|
4
|
+
class StackTrace
|
5
|
+
BACKTRACE_LINE_REGEX = /^((?:[a-zA-Z]:)?[^:]+):(\d+)(?::in `([^']+)')?$/.freeze
|
6
|
+
|
7
|
+
attr_accessor :stack_trace, :lines
|
8
|
+
|
9
|
+
def initialize(stack_trace)
|
10
|
+
@stack_trace = stack_trace
|
11
|
+
@lines = stack_trace.map do |line|
|
12
|
+
next unless line.match(BACKTRACE_LINE_REGEX)
|
13
|
+
{
|
14
|
+
file: Regexp.last_match(1),
|
15
|
+
line_number: Regexp.last_match(2).to_i,
|
16
|
+
method: Regexp.last_match(3),
|
17
|
+
}
|
18
|
+
end.compact
|
19
|
+
|
20
|
+
# Hack to remove TaintedLove.proxy_method
|
21
|
+
@lines.shift if @lines.first[:file]['tainted_love/utils.rb']
|
22
|
+
end
|
23
|
+
|
24
|
+
# Produces a hash from the stack trace to identify identical code path
|
25
|
+
#
|
26
|
+
# @return [String]
|
27
|
+
def trace_hash
|
28
|
+
lines = @lines.map { |line| "#{line[:file]}:#{line[:number]}" }.join(',')
|
29
|
+
TaintedLove.hash(lines)
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_json
|
33
|
+
{
|
34
|
+
trace_hash: trace_hash,
|
35
|
+
}.to_json
|
36
|
+
end
|
37
|
+
|
38
|
+
# Create a new StackTrace object from the current thread backtrace
|
39
|
+
#
|
40
|
+
# @param skip [Integer] number of trace line to skip
|
41
|
+
# @return [TaintedLove::StackTrace]
|
42
|
+
def self.current(skip = 2)
|
43
|
+
new(Thread.current.backtrace(skip))
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'digest/md5'
|
4
|
+
|
5
|
+
module TaintedLove
|
6
|
+
module Utils
|
7
|
+
# Replaces a method defined in klass.
|
8
|
+
#
|
9
|
+
# @param klass [Class, String] The target class
|
10
|
+
# @param method [Symbol] The method name to replace
|
11
|
+
# @param replace_return_value [Boolean]
|
12
|
+
# If true, the return value of the function will be the value returned by the block.
|
13
|
+
# Otherwise, the function will return its original value.
|
14
|
+
# @yield [*args, &block] Block to execute when the function is called
|
15
|
+
def proxy_method(klass, method, replace_return_value = false, &block)
|
16
|
+
if klass.is_a?(String)
|
17
|
+
if Object.const_defined?(klass)
|
18
|
+
klass = Object.const_get(klass)
|
19
|
+
else
|
20
|
+
return
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
original_method = "_tainted_love_original_#{method}"
|
25
|
+
|
26
|
+
klass.class_eval do
|
27
|
+
alias_method original_method, method
|
28
|
+
|
29
|
+
define_method method do |*args, &given_block|
|
30
|
+
return_value = send(original_method, *args, &given_block)
|
31
|
+
|
32
|
+
block_return = block.call(return_value, *args, self, &block)
|
33
|
+
|
34
|
+
if replace_return_value
|
35
|
+
block_return
|
36
|
+
else
|
37
|
+
return_value
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Adds information about the object. The information can be about
|
44
|
+
# where the object is coming from, validation that has been done on the object, etc.
|
45
|
+
#
|
46
|
+
# If the object is frozen, the given block will be called with a new object.
|
47
|
+
# The caller has the responsability of replacing the frozen object with this
|
48
|
+
# new object.
|
49
|
+
#
|
50
|
+
# @param object [Object] Object to add tracking
|
51
|
+
# @param payload [Hash] Data to add to the object
|
52
|
+
# @yield [Object] Invoked with a duplicate unfrozen version of object
|
53
|
+
# @return [Object] Given object or dup of it
|
54
|
+
def add_tracking(object, payload = {}, &block)
|
55
|
+
frozen = object.frozen?
|
56
|
+
|
57
|
+
return if frozen && block.nil?
|
58
|
+
|
59
|
+
payload[:stacktrace] = StackTrace.current
|
60
|
+
|
61
|
+
object = object.dup if frozen
|
62
|
+
|
63
|
+
object.tainted_love_tracking << payload
|
64
|
+
|
65
|
+
block.call(object) if frozen
|
66
|
+
|
67
|
+
object
|
68
|
+
end
|
69
|
+
|
70
|
+
# Create a hex encoded MD5 hash
|
71
|
+
#
|
72
|
+
# @params str [String] Input string
|
73
|
+
# @returns [String]
|
74
|
+
def hash(str)
|
75
|
+
h = Digest::MD5.new
|
76
|
+
h.update(str)
|
77
|
+
h.hexdigest
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TaintedLove
|
4
|
+
module Validator
|
5
|
+
class ActionViewObjectSend < Base
|
6
|
+
def remove?(warning)
|
7
|
+
return unless warning.replacer == :ReplaceObject
|
8
|
+
|
9
|
+
if warning.stack_trace.lines.first[:file]['actionview/template.rb']
|
10
|
+
return true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TaintedLove
|
4
|
+
# Validator are used to prevent false positives based on user input, stack trace,
|
5
|
+
# Ruby version or gem version.
|
6
|
+
module Validator
|
7
|
+
class Base
|
8
|
+
def self.validators
|
9
|
+
TaintedLove::Validator.constants.map do |const|
|
10
|
+
cls = TaintedLove::Validator.const_get(const)
|
11
|
+
cls if cls.method_defined?(:remove?)
|
12
|
+
end.compact
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TaintedLove
|
4
|
+
module Validator
|
5
|
+
class ErbEval < Base
|
6
|
+
def remove?(warning)
|
7
|
+
if Object.const_defined?('Rails') || Object.const_defined?('ERB')
|
8
|
+
return true if warning.tainted_input['_erbout']
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TaintedLove
|
4
|
+
module Validator
|
5
|
+
# Assumes that value unserialized from Redis are safe
|
6
|
+
class RedisStoreSerialization < Base
|
7
|
+
def remove?(warning)
|
8
|
+
warning.replacer == :ReplaceMarshal &&
|
9
|
+
warning.stack_trace_line[:file]['redis/store/serialization.rb']
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TaintedLove
|
4
|
+
module Validator
|
5
|
+
class SproketsMarshal < Base
|
6
|
+
def remove?(warning)
|
7
|
+
calling = warning.stack_trace.lines.first
|
8
|
+
|
9
|
+
if calling[:method] == "unmarshaled_deflated" && calling[:file][/sprockets/]
|
10
|
+
return true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TaintedLove
|
4
|
+
class Warning
|
5
|
+
attr_accessor :stack_trace, :replacer, :tainted_input, :reported_at, :message, :tags
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@reported_at = Time.now.to_i
|
9
|
+
end
|
10
|
+
|
11
|
+
def ==(other)
|
12
|
+
stack_trace == other.stack_trace && tainted_input == other.tainted_input
|
13
|
+
end
|
14
|
+
|
15
|
+
def stack_trace_line
|
16
|
+
@stack_trace.lines.first
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_json
|
20
|
+
{
|
21
|
+
stack_trace: @stack_trace,
|
22
|
+
replacer: @replacer,
|
23
|
+
tainted_input: @tainted_input,
|
24
|
+
reported_at: @reported_at,
|
25
|
+
message: @message,
|
26
|
+
tags: @tags,
|
27
|
+
}.to_json
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'tainted_love/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'tainted_love'
|
9
|
+
spec.version = TaintedLove::VERSION
|
10
|
+
spec.authors = ['Benoit Cote-Jodoin']
|
11
|
+
spec.email = ['benoit.cotejodoin@shopify.com']
|
12
|
+
|
13
|
+
spec.summary = 'TaintedLove is a dynamic security analysis tool for Ruby'
|
14
|
+
spec.homepage = 'https://github.com/Shopify/tainted_love'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
20
|
+
%x(git ls-files -z).split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
end
|
22
|
+
spec.bindir = 'exe'
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = %w[lib]
|
25
|
+
|
26
|
+
spec.add_development_dependency('bundler', '~> 1.17')
|
27
|
+
spec.add_development_dependency('rake', '~> 10.0')
|
28
|
+
spec.add_development_dependency('rspec', '~> 3.0')
|
29
|
+
spec.add_development_dependency('rubocop', '~> 0.65.0')
|
30
|
+
spec.add_development_dependency('yard', '~> 0.9.18')
|
31
|
+
end
|