Skip to content

Commit

Permalink
Merge pull request #1 from faraazahmad/housekeeping
Browse files Browse the repository at this point in the history
chore: perform housekeeping
  • Loading branch information
faraazahmad authored Nov 4, 2023
2 parents 4af331b + 58db382 commit 158bc8e
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 20 deletions.
8 changes: 2 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@

source "https://rubygems.org"

# gem "rails"

gem "syntax_tree", "~> 6.2"

gem "rubocop", "~> 1.57", groups: %i[development test]

gem "rake", "~> 13.0", :groups => [:development, :test]

gem "rspec", "~> 3.12", :groups => [:development, :test]
gem "rake", "~> 13.0", groups: %i[development test]
gem "rspec", "~> 3.12", groups: %i[development test]
2 changes: 1 addition & 1 deletion lib/tainted/lint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Lint
def initialize(filepath, sources, sinks)
@filepath = filepath

t = Tainted::DataFlow.new(@filepath)
t = DataFlow.new(@filepath)
t.generate
var_dependencies = t.tainted
State.instance.var_dependencies = var_dependencies
Expand Down
5 changes: 4 additions & 1 deletion lib/tainted/static.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ module Tainted
class Static < SyntaxTree::Visitor
attr_reader :result

def initialize(sources, _sinks)
def initialize(sources, sinks)
super()

@sources = sources
@sinks = sinks
@result = []
end

Expand Down Expand Up @@ -45,6 +46,8 @@ def parse_call(node)
arguments.map { |arg| [arg, taint_status(arg.value.value.to_sym)] }

method_name = node.message.value
return unless @sinks.include?(method_name.to_sym)

taint_statuses.each do |status|
next unless status[1]

Expand Down
File renamed without changes.
18 changes: 18 additions & 0 deletions spec/lib/tainted/lint_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_stirng_literal: true

RSpec.describe Tainted::Lint do
context "Given a file with tainted sources and sinks" do
it "returns a result listing the taint errors" do
file = File.expand_path "#{__dir__}/../../fixtures/simple.rb"
lint = Tainted::Lint.new(file, %i[tainted], %i[unsafe])
result = lint.analyze

expect(result).to eq(
[
"Method `unsafe()` consuming tainted variable `d`",
"Method `unsafe()` consuming tainted variable `c`"
]
)
end
end
end
12 changes: 0 additions & 12 deletions spec/tainted_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,4 @@
it "has a version number" do
expect(Tainted::VERSION).not_to be nil
end

it "does something useful" do
file = "#{__dir__}/../fixtures/simple.rb"
lint = Tainted::Lint.new(file, %i[tainted], %i[unsafe])
result = lint.analyze
expect(result).to eq(
[
"Method `unsafe()` consuming tainted variable `d`",
"Method `unsafe()` consuming tainted variable `c`"
]
)
end
end

0 comments on commit 158bc8e

Please sign in to comment.