##// END OF EJS Templates
push: add tests for unsafe ssh url (SEC)
Sean Farley -
r33728:48d520fd stable
parent child Browse files
Show More
@@ -1,318 +1,337 b''
1 ==================================
1 ==================================
2 Basic testing for the push command
2 Basic testing for the push command
3 ==================================
3 ==================================
4
4
5 Testing of the '--rev' flag
5 Testing of the '--rev' flag
6 ===========================
6 ===========================
7
7
8 $ hg init test-revflag
8 $ hg init test-revflag
9 $ hg -R test-revflag unbundle "$TESTDIR/bundles/remote.hg"
9 $ hg -R test-revflag unbundle "$TESTDIR/bundles/remote.hg"
10 adding changesets
10 adding changesets
11 adding manifests
11 adding manifests
12 adding file changes
12 adding file changes
13 added 9 changesets with 7 changes to 4 files (+1 heads)
13 added 9 changesets with 7 changes to 4 files (+1 heads)
14 (run 'hg heads' to see heads, 'hg merge' to merge)
14 (run 'hg heads' to see heads, 'hg merge' to merge)
15
15
16 $ for i in 0 1 2 3 4 5 6 7 8; do
16 $ for i in 0 1 2 3 4 5 6 7 8; do
17 > echo
17 > echo
18 > hg init test-revflag-"$i"
18 > hg init test-revflag-"$i"
19 > hg -R test-revflag push -r "$i" test-revflag-"$i"
19 > hg -R test-revflag push -r "$i" test-revflag-"$i"
20 > hg -R test-revflag-"$i" verify
20 > hg -R test-revflag-"$i" verify
21 > done
21 > done
22
22
23 pushing to test-revflag-0
23 pushing to test-revflag-0
24 searching for changes
24 searching for changes
25 adding changesets
25 adding changesets
26 adding manifests
26 adding manifests
27 adding file changes
27 adding file changes
28 added 1 changesets with 1 changes to 1 files
28 added 1 changesets with 1 changes to 1 files
29 checking changesets
29 checking changesets
30 checking manifests
30 checking manifests
31 crosschecking files in changesets and manifests
31 crosschecking files in changesets and manifests
32 checking files
32 checking files
33 1 files, 1 changesets, 1 total revisions
33 1 files, 1 changesets, 1 total revisions
34
34
35 pushing to test-revflag-1
35 pushing to test-revflag-1
36 searching for changes
36 searching for changes
37 adding changesets
37 adding changesets
38 adding manifests
38 adding manifests
39 adding file changes
39 adding file changes
40 added 2 changesets with 2 changes to 1 files
40 added 2 changesets with 2 changes to 1 files
41 checking changesets
41 checking changesets
42 checking manifests
42 checking manifests
43 crosschecking files in changesets and manifests
43 crosschecking files in changesets and manifests
44 checking files
44 checking files
45 1 files, 2 changesets, 2 total revisions
45 1 files, 2 changesets, 2 total revisions
46
46
47 pushing to test-revflag-2
47 pushing to test-revflag-2
48 searching for changes
48 searching for changes
49 adding changesets
49 adding changesets
50 adding manifests
50 adding manifests
51 adding file changes
51 adding file changes
52 added 3 changesets with 3 changes to 1 files
52 added 3 changesets with 3 changes to 1 files
53 checking changesets
53 checking changesets
54 checking manifests
54 checking manifests
55 crosschecking files in changesets and manifests
55 crosschecking files in changesets and manifests
56 checking files
56 checking files
57 1 files, 3 changesets, 3 total revisions
57 1 files, 3 changesets, 3 total revisions
58
58
59 pushing to test-revflag-3
59 pushing to test-revflag-3
60 searching for changes
60 searching for changes
61 adding changesets
61 adding changesets
62 adding manifests
62 adding manifests
63 adding file changes
63 adding file changes
64 added 4 changesets with 4 changes to 1 files
64 added 4 changesets with 4 changes to 1 files
65 checking changesets
65 checking changesets
66 checking manifests
66 checking manifests
67 crosschecking files in changesets and manifests
67 crosschecking files in changesets and manifests
68 checking files
68 checking files
69 1 files, 4 changesets, 4 total revisions
69 1 files, 4 changesets, 4 total revisions
70
70
71 pushing to test-revflag-4
71 pushing to test-revflag-4
72 searching for changes
72 searching for changes
73 adding changesets
73 adding changesets
74 adding manifests
74 adding manifests
75 adding file changes
75 adding file changes
76 added 2 changesets with 2 changes to 1 files
76 added 2 changesets with 2 changes to 1 files
77 checking changesets
77 checking changesets
78 checking manifests
78 checking manifests
79 crosschecking files in changesets and manifests
79 crosschecking files in changesets and manifests
80 checking files
80 checking files
81 1 files, 2 changesets, 2 total revisions
81 1 files, 2 changesets, 2 total revisions
82
82
83 pushing to test-revflag-5
83 pushing to test-revflag-5
84 searching for changes
84 searching for changes
85 adding changesets
85 adding changesets
86 adding manifests
86 adding manifests
87 adding file changes
87 adding file changes
88 added 3 changesets with 3 changes to 1 files
88 added 3 changesets with 3 changes to 1 files
89 checking changesets
89 checking changesets
90 checking manifests
90 checking manifests
91 crosschecking files in changesets and manifests
91 crosschecking files in changesets and manifests
92 checking files
92 checking files
93 1 files, 3 changesets, 3 total revisions
93 1 files, 3 changesets, 3 total revisions
94
94
95 pushing to test-revflag-6
95 pushing to test-revflag-6
96 searching for changes
96 searching for changes
97 adding changesets
97 adding changesets
98 adding manifests
98 adding manifests
99 adding file changes
99 adding file changes
100 added 4 changesets with 5 changes to 2 files
100 added 4 changesets with 5 changes to 2 files
101 checking changesets
101 checking changesets
102 checking manifests
102 checking manifests
103 crosschecking files in changesets and manifests
103 crosschecking files in changesets and manifests
104 checking files
104 checking files
105 2 files, 4 changesets, 5 total revisions
105 2 files, 4 changesets, 5 total revisions
106
106
107 pushing to test-revflag-7
107 pushing to test-revflag-7
108 searching for changes
108 searching for changes
109 adding changesets
109 adding changesets
110 adding manifests
110 adding manifests
111 adding file changes
111 adding file changes
112 added 5 changesets with 6 changes to 3 files
112 added 5 changesets with 6 changes to 3 files
113 checking changesets
113 checking changesets
114 checking manifests
114 checking manifests
115 crosschecking files in changesets and manifests
115 crosschecking files in changesets and manifests
116 checking files
116 checking files
117 3 files, 5 changesets, 6 total revisions
117 3 files, 5 changesets, 6 total revisions
118
118
119 pushing to test-revflag-8
119 pushing to test-revflag-8
120 searching for changes
120 searching for changes
121 adding changesets
121 adding changesets
122 adding manifests
122 adding manifests
123 adding file changes
123 adding file changes
124 added 5 changesets with 5 changes to 2 files
124 added 5 changesets with 5 changes to 2 files
125 checking changesets
125 checking changesets
126 checking manifests
126 checking manifests
127 crosschecking files in changesets and manifests
127 crosschecking files in changesets and manifests
128 checking files
128 checking files
129 2 files, 5 changesets, 5 total revisions
129 2 files, 5 changesets, 5 total revisions
130
130
131 $ cd test-revflag-8
131 $ cd test-revflag-8
132
132
133 $ hg pull ../test-revflag-7
133 $ hg pull ../test-revflag-7
134 pulling from ../test-revflag-7
134 pulling from ../test-revflag-7
135 searching for changes
135 searching for changes
136 adding changesets
136 adding changesets
137 adding manifests
137 adding manifests
138 adding file changes
138 adding file changes
139 added 4 changesets with 2 changes to 3 files (+1 heads)
139 added 4 changesets with 2 changes to 3 files (+1 heads)
140 (run 'hg heads' to see heads, 'hg merge' to merge)
140 (run 'hg heads' to see heads, 'hg merge' to merge)
141
141
142 $ hg verify
142 $ hg verify
143 checking changesets
143 checking changesets
144 checking manifests
144 checking manifests
145 crosschecking files in changesets and manifests
145 crosschecking files in changesets and manifests
146 checking files
146 checking files
147 4 files, 9 changesets, 7 total revisions
147 4 files, 9 changesets, 7 total revisions
148
148
149 $ cd ..
149 $ cd ..
150
150
151 Test server side validation during push
151 Test server side validation during push
152 =======================================
152 =======================================
153
153
154 $ hg init test-validation
154 $ hg init test-validation
155 $ cd test-validation
155 $ cd test-validation
156
156
157 $ cat > .hg/hgrc <<EOF
157 $ cat > .hg/hgrc <<EOF
158 > [server]
158 > [server]
159 > validate=1
159 > validate=1
160 > EOF
160 > EOF
161
161
162 $ echo alpha > alpha
162 $ echo alpha > alpha
163 $ echo beta > beta
163 $ echo beta > beta
164 $ hg addr
164 $ hg addr
165 adding alpha
165 adding alpha
166 adding beta
166 adding beta
167 $ hg ci -m 1
167 $ hg ci -m 1
168
168
169 $ cd ..
169 $ cd ..
170 $ hg clone test-validation test-validation-clone
170 $ hg clone test-validation test-validation-clone
171 updating to branch default
171 updating to branch default
172 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
172 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
173
173
174 Test spurious filelog entries:
174 Test spurious filelog entries:
175
175
176 $ cd test-validation-clone
176 $ cd test-validation-clone
177 $ echo blah >> beta
177 $ echo blah >> beta
178 $ cp .hg/store/data/beta.i tmp1
178 $ cp .hg/store/data/beta.i tmp1
179 $ hg ci -m 2
179 $ hg ci -m 2
180 $ cp .hg/store/data/beta.i tmp2
180 $ cp .hg/store/data/beta.i tmp2
181 $ hg -q rollback
181 $ hg -q rollback
182 $ mv tmp2 .hg/store/data/beta.i
182 $ mv tmp2 .hg/store/data/beta.i
183 $ echo blah >> beta
183 $ echo blah >> beta
184 $ hg ci -m '2 (corrupt)'
184 $ hg ci -m '2 (corrupt)'
185
185
186 Expected to fail:
186 Expected to fail:
187
187
188 $ hg verify
188 $ hg verify
189 checking changesets
189 checking changesets
190 checking manifests
190 checking manifests
191 crosschecking files in changesets and manifests
191 crosschecking files in changesets and manifests
192 checking files
192 checking files
193 beta@1: dddc47b3ba30 not in manifests
193 beta@1: dddc47b3ba30 not in manifests
194 2 files, 2 changesets, 4 total revisions
194 2 files, 2 changesets, 4 total revisions
195 1 integrity errors encountered!
195 1 integrity errors encountered!
196 (first damaged changeset appears to be 1)
196 (first damaged changeset appears to be 1)
197 [1]
197 [1]
198
198
199 $ hg push
199 $ hg push
200 pushing to $TESTTMP/test-validation (glob)
200 pushing to $TESTTMP/test-validation (glob)
201 searching for changes
201 searching for changes
202 adding changesets
202 adding changesets
203 adding manifests
203 adding manifests
204 adding file changes
204 adding file changes
205 transaction abort!
205 transaction abort!
206 rollback completed
206 rollback completed
207 abort: received spurious file revlog entry
207 abort: received spurious file revlog entry
208 [255]
208 [255]
209
209
210 $ hg -q rollback
210 $ hg -q rollback
211 $ mv tmp1 .hg/store/data/beta.i
211 $ mv tmp1 .hg/store/data/beta.i
212 $ echo beta > beta
212 $ echo beta > beta
213
213
214 Test missing filelog entries:
214 Test missing filelog entries:
215
215
216 $ cp .hg/store/data/beta.i tmp
216 $ cp .hg/store/data/beta.i tmp
217 $ echo blah >> beta
217 $ echo blah >> beta
218 $ hg ci -m '2 (corrupt)'
218 $ hg ci -m '2 (corrupt)'
219 $ mv tmp .hg/store/data/beta.i
219 $ mv tmp .hg/store/data/beta.i
220
220
221 Expected to fail:
221 Expected to fail:
222
222
223 $ hg verify
223 $ hg verify
224 checking changesets
224 checking changesets
225 checking manifests
225 checking manifests
226 crosschecking files in changesets and manifests
226 crosschecking files in changesets and manifests
227 checking files
227 checking files
228 beta@1: manifest refers to unknown revision dddc47b3ba30
228 beta@1: manifest refers to unknown revision dddc47b3ba30
229 2 files, 2 changesets, 2 total revisions
229 2 files, 2 changesets, 2 total revisions
230 1 integrity errors encountered!
230 1 integrity errors encountered!
231 (first damaged changeset appears to be 1)
231 (first damaged changeset appears to be 1)
232 [1]
232 [1]
233
233
234 $ hg push
234 $ hg push
235 pushing to $TESTTMP/test-validation (glob)
235 pushing to $TESTTMP/test-validation (glob)
236 searching for changes
236 searching for changes
237 adding changesets
237 adding changesets
238 adding manifests
238 adding manifests
239 adding file changes
239 adding file changes
240 transaction abort!
240 transaction abort!
241 rollback completed
241 rollback completed
242 abort: missing file data for beta:dddc47b3ba30e54484720ce0f4f768a0f4b6efb9 - run hg verify
242 abort: missing file data for beta:dddc47b3ba30e54484720ce0f4f768a0f4b6efb9 - run hg verify
243 [255]
243 [255]
244
244
245 $ cd ..
245 $ cd ..
246
246
247 Test push hook locking
247 Test push hook locking
248 =====================
248 =====================
249
249
250 $ hg init 1
250 $ hg init 1
251
251
252 $ echo '[ui]' >> 1/.hg/hgrc
252 $ echo '[ui]' >> 1/.hg/hgrc
253 $ echo 'timeout = 10' >> 1/.hg/hgrc
253 $ echo 'timeout = 10' >> 1/.hg/hgrc
254
254
255 $ echo foo > 1/foo
255 $ echo foo > 1/foo
256 $ hg --cwd 1 ci -A -m foo
256 $ hg --cwd 1 ci -A -m foo
257 adding foo
257 adding foo
258
258
259 $ hg clone 1 2
259 $ hg clone 1 2
260 updating to branch default
260 updating to branch default
261 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
261 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
262
262
263 $ hg clone 2 3
263 $ hg clone 2 3
264 updating to branch default
264 updating to branch default
265 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
265 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
266
266
267 $ cat <<EOF > $TESTTMP/debuglocks-pretxn-hook.sh
267 $ cat <<EOF > $TESTTMP/debuglocks-pretxn-hook.sh
268 > hg debuglocks
268 > hg debuglocks
269 > true
269 > true
270 > EOF
270 > EOF
271 $ echo '[hooks]' >> 2/.hg/hgrc
271 $ echo '[hooks]' >> 2/.hg/hgrc
272 $ echo "pretxnchangegroup.a = sh $TESTTMP/debuglocks-pretxn-hook.sh" >> 2/.hg/hgrc
272 $ echo "pretxnchangegroup.a = sh $TESTTMP/debuglocks-pretxn-hook.sh" >> 2/.hg/hgrc
273 $ echo 'changegroup.push = hg push -qf ../1' >> 2/.hg/hgrc
273 $ echo 'changegroup.push = hg push -qf ../1' >> 2/.hg/hgrc
274
274
275 $ echo bar >> 3/foo
275 $ echo bar >> 3/foo
276 $ hg --cwd 3 ci -m bar
276 $ hg --cwd 3 ci -m bar
277
277
278 $ hg --cwd 3 push ../2 --config devel.legacy.exchange=bundle1
278 $ hg --cwd 3 push ../2 --config devel.legacy.exchange=bundle1
279 pushing to ../2
279 pushing to ../2
280 searching for changes
280 searching for changes
281 adding changesets
281 adding changesets
282 adding manifests
282 adding manifests
283 adding file changes
283 adding file changes
284 added 1 changesets with 1 changes to 1 files
284 added 1 changesets with 1 changes to 1 files
285 lock: user *, process * (*s) (glob)
285 lock: user *, process * (*s) (glob)
286 wlock: free
286 wlock: free
287
287
288 $ hg --cwd 1 --config extensions.strip= strip tip -q
288 $ hg --cwd 1 --config extensions.strip= strip tip -q
289 $ hg --cwd 2 --config extensions.strip= strip tip -q
289 $ hg --cwd 2 --config extensions.strip= strip tip -q
290 $ hg --cwd 3 push ../2 # bundle2+
290 $ hg --cwd 3 push ../2 # bundle2+
291 pushing to ../2
291 pushing to ../2
292 searching for changes
292 searching for changes
293 adding changesets
293 adding changesets
294 adding manifests
294 adding manifests
295 adding file changes
295 adding file changes
296 added 1 changesets with 1 changes to 1 files
296 added 1 changesets with 1 changes to 1 files
297 lock: user *, process * (*s) (glob)
297 lock: user *, process * (*s) (glob)
298 wlock: user *, process * (*s) (glob)
298 wlock: user *, process * (*s) (glob)
299
299
300 Test bare push with multiple race checking options
300 Test bare push with multiple race checking options
301 --------------------------------------------------
301 --------------------------------------------------
302
302
303 $ hg init test-bare-push-no-concurrency
303 $ hg init test-bare-push-no-concurrency
304 $ hg init test-bare-push-unrelated-concurrency
304 $ hg init test-bare-push-unrelated-concurrency
305 $ hg -R test-revflag push -r 0 test-bare-push-no-concurrency --config server.concurrent-push-mode=strict
305 $ hg -R test-revflag push -r 0 test-bare-push-no-concurrency --config server.concurrent-push-mode=strict
306 pushing to test-bare-push-no-concurrency
306 pushing to test-bare-push-no-concurrency
307 searching for changes
307 searching for changes
308 adding changesets
308 adding changesets
309 adding manifests
309 adding manifests
310 adding file changes
310 adding file changes
311 added 1 changesets with 1 changes to 1 files
311 added 1 changesets with 1 changes to 1 files
312 $ hg -R test-revflag push -r 0 test-bare-push-unrelated-concurrency --config server.concurrent-push-mode=check-related
312 $ hg -R test-revflag push -r 0 test-bare-push-unrelated-concurrency --config server.concurrent-push-mode=check-related
313 pushing to test-bare-push-unrelated-concurrency
313 pushing to test-bare-push-unrelated-concurrency
314 searching for changes
314 searching for changes
315 adding changesets
315 adding changesets
316 adding manifests
316 adding manifests
317 adding file changes
317 adding file changes
318 added 1 changesets with 1 changes to 1 files
318 added 1 changesets with 1 changes to 1 files
319
320 SEC: check for unsafe ssh url
321
322 $ hg -R test-revflag push 'ssh://-oProxyCommand=touch${IFS}owned/path'
323 pushing to ssh://-oProxyCommand%3Dtouch%24%7BIFS%7Downed/path
324 abort: potentially unsafe url: 'ssh://-oProxyCommand=touch${IFS}owned/path'
325 [255]
326 $ hg -R test-revflag push 'ssh://%2DoProxyCommand=touch${IFS}owned/path'
327 pushing to ssh://-oProxyCommand%3Dtouch%24%7BIFS%7Downed/path
328 abort: potentially unsafe url: 'ssh://-oProxyCommand=touch${IFS}owned/path'
329 [255]
330 $ hg -R test-revflag push 'ssh://fakehost|shellcommand/path'
331 pushing to ssh://fakehost%7Cshellcommand/path
332 abort: potentially unsafe url: 'ssh://fakehost|shellcommand/path'
333 [255]
334 $ hg -R test-revflag push 'ssh://fakehost%7Cshellcommand/path'
335 pushing to ssh://fakehost%7Cshellcommand/path
336 abort: potentially unsafe url: 'ssh://fakehost|shellcommand/path'
337 [255]
General Comments 0
You need to be logged in to leave comments. Login now