-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Escape user input with Open3 capture (#702)
- use Open3.capture3 for rsync instead of backticks in most cases - dashboard: remove broken 'active_users' feature from developer dashboard - myjobs: stick with rsync and Shellwords.escape for rsync command since using filter argument with Open3.capture3 is problematic - myjobs: fix error reporting on new template page (display all error messages as bullet list at top of form) and fix focus
- Loading branch information
Showing
8 changed files
with
103 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require 'test_helper' | ||
|
||
class FilesystemTest < ActiveSupport::TestCase | ||
test "copy_dir copies directories excluding .git .svn and files in gitignore" do | ||
Dir.mktmpdir do |dir| | ||
tmp = Pathname.new(dir).join('t') | ||
tmp2 = Pathname.new(dir).join('t2') | ||
|
||
Filesystem.new.copy_dir Rails.root.join('example_templates', 'default'), tmp | ||
|
||
assert_equal 2, tmp.children.count, "job script and manifest should have been copied" | ||
|
||
tmp.join('.gitignore').write('manifest.yml') | ||
tmp.join('.git').mkpath | ||
tmp.join('.svn').mkpath | ||
|
||
Filesystem.new.copy_dir tmp, tmp2 | ||
|
||
assert_equal 1, tmp2.children.count, "only job template should exist cause the manifest.yml should have been ignored" | ||
end | ||
end | ||
|
||
test "copy_dir doesn't allow command injection" do | ||
o,s = Filesystem.new.copy_dir("/dev/null';echo INJECTED;'", '/dev/null') | ||
assert_equal 0, o.split("\n").grep(/^INJECTED$/).count, "expected not to find INJECTED in output: #{o}" | ||
end | ||
end |