Skip to content

Commit

Permalink
Add test for scanning jobs directory
Browse files Browse the repository at this point in the history
  • Loading branch information
presidentbeef committed Mar 22, 2018
1 parent 746ea3e commit 9855776
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions test/apps/rails5.2/app/jobs/delete_stuff_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class DeleteStuffJob < ApplicationJob
def perform file
`rm -rf #{file}`
end
end
15 changes: 14 additions & 1 deletion test/tests/rails52.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def expected
:controller => 0,
:model => 0,
:template => 0,
:generic => 2
:generic => 3
}
end

Expand Down Expand Up @@ -53,6 +53,19 @@ def test_command_injection_1
:user_input => s(:ivar, :@blah)
end

def test_command_injection_in_job
assert_warning :type => :warning,
:warning_code => 14,
:fingerprint => "e712e2741ad78f4e947bec84f36a0d703849d3b0facdabd8cc74851d7b702a48",
:warning_type => "Command Injection",
:line => 3,
:message => /^Possible\ command\ injection/,
:confidence => 1,
:relative_path => "app/jobs/delete_stuff_job.rb",
:code => s(:dxstr, "rm -rf ", s(:evstr, s(:lvar, :file))),
:user_input => s(:lvar, :file)
end

def test_command_injection_shellwords
assert_no_warning :type => :warning,
:warning_code => 14,
Expand Down

0 comments on commit 9855776

Please sign in to comment.