tainted 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b26e5de6db90715d8868475b14f828ee951472378e2ab3d751bb36e0ab570a1
4
- data.tar.gz: 4e84f893cefc8c37f52b9b353ff80ea3a63eba096f625d6acb2061aefb83d299
3
+ metadata.gz: 2d61982c033f50c5e79a00dc34ef94fe612400097ef70e2e934d6def3f28cfac
4
+ data.tar.gz: 55314168a8b4a3026e4c0cf9c9c61adcd277ed306ef656078b29f9930cff8dcd
5
5
  SHA512:
6
- metadata.gz: 2a73d2e0c62366eb397b64c7f4cd8d78f643ba1179bafa4534664c901cadc683d3b1d375a205024e0716930d17634076de122e36e3f96c2c8f53f0310ac747c9
7
- data.tar.gz: f1444e63ab1f1fa2cbb328b19d2676c5eabc5948ae6a4bc7af0167ce08c7dd898ea5ee203629ab30adec04c76d0ed652c1966ff008c4806775d8e4039726aaeb
6
+ metadata.gz: a211a22a04214a44ddb858930a69af6014f2c18aeb23c86c63ebcfbb8034f6f2da2d2f541088314fed8a0a59eb2a410ea9a9ca9e5527a89bef08e168a60eac5d
7
+ data.tar.gz: 1da46aac7509d85177687d1b4f1ab06824d6f7e944c2404dfc249cffe17c3cf9eb29b9470ca7914df86b113c8134655ee5a06e6c533a3164544fa4e6935b179e
data/Rakefile CHANGED
@@ -9,4 +9,4 @@ require "rubocop/rake_task"
9
9
 
10
10
  RuboCop::RakeTask.new
11
11
 
12
- task default: %i[spec rubocop]
12
+ task default: %i[spec]
data/lib/tainted/lint.rb CHANGED
@@ -5,7 +5,7 @@ module Tainted
5
5
  def initialize(filepath, sources, sinks)
6
6
  @filepath = filepath
7
7
 
8
- t = Tainted::DataFlow.new(@filepath)
8
+ t = DataFlow.new(@filepath)
9
9
  t.generate
10
10
  var_dependencies = t.tainted
11
11
  State.instance.var_dependencies = var_dependencies
@@ -4,10 +4,11 @@ module Tainted
4
4
  class Static < SyntaxTree::Visitor
5
5
  attr_reader :result
6
6
 
7
- def initialize(sources, _sinks)
7
+ def initialize(sources, sinks)
8
8
  super()
9
9
 
10
10
  @sources = sources
11
+ @sinks = sinks
11
12
  @result = []
12
13
  end
13
14
 
@@ -29,10 +30,17 @@ module Tainted
29
30
 
30
31
  def parse_assign(node)
31
32
  variable_name = node.target.value.value
32
- # pp node.value.class
33
- return unless node.value.is_a?(SyntaxTree::CallNode)
34
33
 
35
- method_name = node.value.message.value
34
+ method_name =
35
+ case node.value
36
+ when SyntaxTree::CallNode
37
+ node.value.message.value
38
+ when SyntaxTree::ARef
39
+ # (aref (vcall (ident "<method_name>")))
40
+ node.value.collection.value.value
41
+ end
42
+
43
+ return if method_name.nil?
36
44
  return unless @sources.include?(method_name&.to_sym)
37
45
 
38
46
  State.instance.var_dependencies[variable_name.to_sym][:tainted] = true
@@ -45,6 +53,8 @@ module Tainted
45
53
  arguments.map { |arg| [arg, taint_status(arg.value.value.to_sym)] }
46
54
 
47
55
  method_name = node.message.value
56
+ return unless @sinks.include?(method_name.to_sym)
57
+
48
58
  taint_statuses.each do |status|
49
59
  next unless status[1]
50
60
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tainted
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tainted
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Syed Faraaz Ahmad
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-23 00:00:00.000000000 Z
11
+ date: 2023-11-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -23,7 +23,6 @@ files:
23
23
  - LICENSE.txt
24
24
  - README.md
25
25
  - Rakefile
26
- - fixtures/simple.rb
27
26
  - lib/tainted.rb
28
27
  - lib/tainted/dataflow.rb
29
28
  - lib/tainted/lint.rb
data/fixtures/simple.rb DELETED
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- a = tainted()
4
- b = a + 1
5
- c = b + 2
6
- d = b + c
7
- unsafe(d)
8
- unsafe(c)