8000 backport - add check before staging (#4367) - to 3.1 by johrstrom · Pull Request #4372 · OSC/ondemand · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

backport - add check before staging (#4367) - to 3.1 #4372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 19, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions apps/myjobs/app/models/workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,16 @@ def stage
self.staged_dir = OSC::Machete::JobDir.new(staging_target_dir).new_jobdir.to_s
FileUtils.mkdir_p self.staged_dir

# have to check for recursion here. Can't copy a parent like all of HOME into the
# destination which is also within your HOME
src = Pathname.new(staged_dir).expand_path.realpath
dest = Pathname.new(staging_template_dir).expand_path.realpath
if src.to_s.start_with?(dest.to_s)
msg = "Source Path (#{staging_template_dir}) cannot be a parent of the destination directory (#{staged_dir})."
errors.add(:staging_template_dir, msg)
throw(:abort)
end

# rsync to ignore manifest.yml
stdout, stderr, status = Open3.capture3 "rsync -r --exclude='manifest.yml' #{Shellwords.escape(staging_template_dir.to_s)}/ #{Shellwords.escape(self.staged_dir)}"
raise IOError if status.exitstatus != 0
Expand Down
Loading
0