lib/cli/commands/apps.rb in vmc-0.3.13.beta.5 vs lib/cli/commands/apps.rb in vmc-0.3.13
- old
+ new
@@ -386,11 +386,10 @@
raise VMC::Client::AuthError unless client.logged_in?
end
# check if we have hit our app limit
check_app_limit
-
# check memsize here for capacity
if memswitch && !no_start
check_has_capacity_for(mem_choice_to_quota(memswitch) * instances)
end
@@ -570,10 +569,21 @@
err 'Deployment path is not a directory' unless File.directory? path
return if File.expand_path(Dir.tmpdir) != File.expand_path(path)
err "Can't deploy applications from staging directory: [#{Dir.tmpdir}]"
end
+ def check_unreachable_links
+ path = Dir.pwd
+ files = Dir.glob("#{path}/**/*", File::FNM_DOTMATCH)
+ unreachable_paths = files.select { |f|
+ File.symlink? f and !File.expand_path(File.readlink(f)).include? path
+ } if files
+ if unreachable_paths.length > 0
+ err "Can't deploy application containing links '#{unreachable_paths}' that reach outside its root '#{path}'"
+ end
+ end
+
def upload_app_bits(appname, path)
display 'Uploading Application:'
upload_file, file = "#{Dir.tmpdir}/#{appname}.zip", nil
FileUtils.rm_f(upload_file)
@@ -584,9 +594,10 @@
Dir.chdir(path) do
# Stage the app appropriately and do the appropriate fingerprinting, etc.
if war_file = Dir.glob('*.war').first
VMC::Cli::ZipUtil.unpack(war_file, explode_dir)
else
+ check_unreachable_links
FileUtils.mkdir(explode_dir)
files = Dir.glob('{*,.[^\.]*}')
# Do not process .git files
files.delete('.git') if files
FileUtils.cp_r(files, explode_dir)