Skip to content
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

Name of resource could break deployment #35

Closed
choubacha opened this issue Dec 13, 2012 · 1 comment
Closed

Name of resource could break deployment #35

choubacha opened this issue Dec 13, 2012 · 1 comment
Milestone

Comments

@choubacha
Copy link

The name of the resource is used in the artifact path but white-space is not removed. If the name contains spaces, for example, the shell commands will most likely fail or behave unpredictably

@artifact_root          = ::File.join(@new_resource.artifact_deploy_path, @new_resource.name)

...

def extract_artifact
  execute "extract_artifact" do
    command "tar xzf #{cached_tar_path} -C #{release_path}"
    user new_resource.owner
    group new_resource.group
  end
end

def copy_artifact
  execute "copy artifact" do
    command "cp #{cached_tar_path} #{release_path}"
    user new_resource.owner
    group new_resource.group
  end
end

In the above code, if the name was "Deploying Files for User" then the command being sent to the execute resource would be:

"cp /tmp/artifacts/Deploying Files for User /home/user"

The spaces will break the shell script and the chef-client will fatally error.

We might try to do a gsub on the name when putting it into artifact_root. Something like:

@artifact_root          = ::File.join(@new_resource.artifact_deploy_path, @new_resource.name.gsub(/\W/, '_'))
@ivey
Copy link
Contributor

ivey commented Dec 13, 2012

Like other resources where the name is significant, the name should be the name of the artifact. I'd be more inclined to support throwing an error on whitespace, or some proper escaping on the shell commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants