Commit aca7f56fef15da8cbe66ec88c1d1a364d4ae8181

Authored by Nigel Kukard
1 parent ce75f46b

Best to escape strings not split them

Signed-off-by: Nigel Kukard <nkukard@lbsd.net>
Showing 1 changed file with 14 additions and 14 deletions   Show diff stats
lib/gitlab/backend/shell.rb
... ... @@ -12,7 +12,7 @@ module Gitlab
12 12 # add_repository("gitlab/gitlab-ci")
13 13 #
14 14 def add_repository(name)
15   - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "add-project", Shellwords.shellwords("#{name}.git")
  15 + system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "add-project", Shellwords.shellescape("#{name}.git")
16 16 end
17 17  
18 18 # Import repository
... ... @@ -23,7 +23,7 @@ module Gitlab
23 23 # import_repository("gitlab/gitlab-ci", "https://github.com/randx/six.git")
24 24 #
25 25 def import_repository(name, url)
26   - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "import-project", Shellwords.shellwords("#{name}.git"), Shellwords.shellwords(url)
  26 + system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "import-project", Shellwords.shellescape("#{name}.git"), Shellwords.shellescape(url)
27 27 end
28 28  
29 29 # Move repository
... ... @@ -35,7 +35,7 @@ module Gitlab
35 35 # mv_repository("gitlab/gitlab-ci", "randx/gitlab-ci-new.git")
36 36 #
37 37 def mv_repository(path, new_path)
38   - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "mv-project", Shellwords.shellwords("#{path}.git"), Shellwords.shellwords("#{new_path}.git")
  38 + system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "mv-project", Shellwords.shellescape("#{path}.git"), Shellwords.shellescape("#{new_path}.git")
39 39 end
40 40  
41 41 # Update HEAD for repository
... ... @@ -47,7 +47,7 @@ module Gitlab
47 47 # update_repository_head("gitlab/gitlab-ci", "3-1-stable")
48 48 #
49 49 def update_repository_head(path, branch)
50   - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "update-head", Shellwords.shellwords("#{path}.git"), Shellwords.shellwords(branch)
  50 + system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "update-head", Shellwords.shellescape("#{path}.git"), Shellwords.shellescape(branch)
51 51 end
52 52  
53 53 # Fork repository to new namespace
... ... @@ -59,18 +59,18 @@ module Gitlab
59 59 # fork_repository("gitlab/gitlab-ci", "randx")
60 60 #
61 61 def fork_repository(path, fork_namespace)
62   - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "fork-project", Shellwords.shellwords("#{path}.git"), Shellwords.shellwords(fork_namespace)
  62 + system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "fork-project", Shellwords.shellescape("#{path}.git"), Shellwords.shellescape(fork_namespace)
63 63 end
64 64  
65 65 # Remove repository from file system
66 66 #
67   - # name - project path with namespace
  67 + # path - project path with namespace
68 68 #
69 69 # Ex.
70 70 # remove_repository("gitlab/gitlab-ci")
71 71 #
72   - def remove_repository(name)
73   - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "rm-project", Shellwords.shellwords("#{name}.git")
  72 + def remove_repository(path)
  73 + system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "rm-project", Shellwords.shellescape("#{path}.git")
74 74 end
75 75  
76 76 # Add repository branch from passed ref
... ... @@ -83,7 +83,7 @@ module Gitlab
83 83 # add_branch("gitlab/gitlab-ci", "4-0-stable", "master")
84 84 #
85 85 def add_branch(path, branch_name, ref)
86   - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "create-branch", Shellwords.shellwords("#{path}.git"), Shellwords.shellwords(branch_name), Shellwords.shellwords(ref)
  86 + system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "create-branch", Shellwords.shellescape("#{path}.git"), Shellwords.shellescape(branch_name), Shellwords.shellescape(ref)
87 87 end
88 88  
89 89 # Remove repository branch
... ... @@ -95,7 +95,7 @@ module Gitlab
95 95 # rm_branch("gitlab/gitlab-ci", "4-0-stable")
96 96 #
97 97 def rm_branch(path, branch_name)
98   - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "rm-branch", Shellwords.shellwords("#{path}.git"), Shellwords.shellwords(branch_name)
  98 + system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "rm-branch", Shellwords.shellescape("#{path}.git"), Shellwords.shellescape(branch_name)
99 99 end
100 100  
101 101 # Add repository tag from passed ref
... ... @@ -108,7 +108,7 @@ module Gitlab
108 108 # add_tag("gitlab/gitlab-ci", "v4.0", "master")
109 109 #
110 110 def add_tag(path, tag_name, ref)
111   - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "create-tag", Shellwords.shellwords("#{path}.git"), Shellwords.shellwords(tag_name), Shellwords.shellwords(ref)
  111 + system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "create-tag", Shellwords.shellescape("#{path}.git"), Shellwords.shellescape(tag_name), Shellwords.shellescape(ref)
112 112 end
113 113  
114 114 # Remove repository tag
... ... @@ -120,7 +120,7 @@ module Gitlab
120 120 # rm_tag("gitlab/gitlab-ci", "v4.0")
121 121 #
122 122 def rm_tag(path, tag_name)
123   - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "rm-tag", Shellwords.shellwords("#{path}.git"), Shellwords.shellwords(tag_name)
  123 + system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "rm-tag", Shellwords.shellescape("#{path}.git"), Shellwords.shellescape(tag_name)
124 124 end
125 125  
126 126 # Add new key to gitlab-shell
... ... @@ -129,7 +129,7 @@ module Gitlab
129 129 # add_key("key-42", "sha-rsa ...")
130 130 #
131 131 def add_key(key_id, key_content)
132   - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-keys", "add-key", Shellwords.shellwords(key_id), Shellwords.shellwords(key_content)
  132 + system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-keys", "add-key", Shellwords.shellescape(key_id), Shellwords.shellescape(key_content)
133 133 end
134 134  
135 135 # Remove ssh key from gitlab shell
... ... @@ -138,7 +138,7 @@ module Gitlab
138 138 # remove_key("key-342", "sha-rsa ...")
139 139 #
140 140 def remove_key(key_id, key_content)
141   - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-keys", "rm-key", Shellwords.shellwords(key_id), Shellwords.shellwords(key_content)
  141 + system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-keys", "rm-key", Shellwords.shellescape(key_id), Shellwords.shellescape(key_content)
142 142 end
143 143  
144 144 # Remove all ssh keys from gitlab shell
... ...