Permalink
Browse files

small fix to accomodate symlinked tmp directories.

Change-Id: I5d82e870c362f3e634061b9e1704aaccc65461ef
  • Loading branch information...
1 parent df09dee commit 5d9831ab4484ac530cac06450bd555e1b7e2dc55 Tal Garfinkel committed with Patrick Bozeman Dec 15, 2011
Showing with 7 additions and 6 deletions.
  1. +6 −5 cloud_controller/app/models/app_package.rb
  2. +1 −1 cloud_controller/spec/models/app_package_spec.rb
@@ -126,12 +126,13 @@ def unpack_upload
working_dir
end
- #enforce property that any file in resource list must be located in the
- #apps directory e.g. '../../foo' or a symlink pointing outside working_dir
- #should raise an exception.
+ # enforce property that any file in resource list must be located in the
+ # apps directory e.g. '../../foo' or a symlink pointing outside working_dir
+ # should raise an exception.
def resolve_path(working_dir, tainted_path)
- expanded_path = File.realdirpath(tainted_path, working_dir)
- pattern = "#{working_dir}/*"
+ expanded_dir = File.realdirpath(working_dir)
+ expanded_path = File.realdirpath(tainted_path, expanded_dir)
+ pattern = "#{expanded_dir}/*"
unless File.fnmatch?(pattern, expanded_path)
raise ArgumentError, "Resource path sanity check failed #{pattern}:#{expanded_path}!!!!"
end
@@ -20,7 +20,7 @@
it 'should succeed if the given path points to a file in the apps directory' do
testpath = File.join(@tmpdir,'testfile')
File.new(testpath, 'w+')
- @app_package.resolve_path(@tmpdir, 'testfile').should == testpath
+ @app_package.resolve_path(@tmpdir, 'testfile').should == File.realdirpath(testpath)
end
it 'should fail if the given path does not resolve to a file in the applications directory' do

0 comments on commit 5d9831a

Please sign in to comment.