##// END OF EJS Templates
pull: add tests for unsafe ssh url (SEC)
Sean Farley -
r33710:92b583e3 stable
parent child Browse files
Show More
@@ -1,108 +1,127 b''
1 1 #require serve
2 2
3 3 $ hg init test
4 4 $ cd test
5 5
6 6 $ echo foo>foo
7 7 $ hg addremove
8 8 adding foo
9 9 $ hg commit -m 1
10 10
11 11 $ hg verify
12 12 checking changesets
13 13 checking manifests
14 14 crosschecking files in changesets and manifests
15 15 checking files
16 16 1 files, 1 changesets, 1 total revisions
17 17
18 18 $ hg serve -p $HGPORT -d --pid-file=hg.pid
19 19 $ cat hg.pid >> $DAEMON_PIDS
20 20 $ cd ..
21 21
22 22 $ hg clone --pull http://foo:bar@localhost:$HGPORT/ copy
23 23 requesting all changes
24 24 adding changesets
25 25 adding manifests
26 26 adding file changes
27 27 added 1 changesets with 1 changes to 1 files
28 28 updating to branch default
29 29 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
30 30
31 31 $ cd copy
32 32 $ hg verify
33 33 checking changesets
34 34 checking manifests
35 35 crosschecking files in changesets and manifests
36 36 checking files
37 37 1 files, 1 changesets, 1 total revisions
38 38
39 39 $ hg co
40 40 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
41 41 $ cat foo
42 42 foo
43 43
44 44 $ hg manifest --debug
45 45 2ed2a3912a0b24502043eae84ee4b279c18b90dd 644 foo
46 46
47 47 $ hg pull
48 48 pulling from http://foo@localhost:$HGPORT/
49 49 searching for changes
50 50 no changes found
51 51
52 52 $ hg rollback --dry-run --verbose
53 53 repository tip rolled back to revision -1 (undo pull: http://foo:***@localhost:$HGPORT/)
54 54
55 55 Test pull of non-existing 20 character revision specification, making sure plain ascii identifiers
56 56 not are encoded like a node:
57 57
58 58 $ hg pull -r 'xxxxxxxxxxxxxxxxxxxy'
59 59 pulling from http://foo@localhost:$HGPORT/
60 60 abort: unknown revision 'xxxxxxxxxxxxxxxxxxxy'!
61 61 [255]
62 62 $ hg pull -r 'xxxxxxxxxxxxxxxxxx y'
63 63 pulling from http://foo@localhost:$HGPORT/
64 64 abort: unknown revision '7878787878787878787878787878787878782079'!
65 65 [255]
66 66
67 67 Issue622: hg init && hg pull -u URL doesn't checkout default branch
68 68
69 69 $ cd ..
70 70 $ hg init empty
71 71 $ cd empty
72 72 $ hg pull -u ../test
73 73 pulling from ../test
74 74 requesting all changes
75 75 adding changesets
76 76 adding manifests
77 77 adding file changes
78 78 added 1 changesets with 1 changes to 1 files
79 79 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
80 80
81 81 Test 'file:' uri handling:
82 82
83 83 $ hg pull -q file://../test-does-not-exist
84 84 abort: file:// URLs can only refer to localhost
85 85 [255]
86 86
87 87 $ hg pull -q file://../test
88 88 abort: file:// URLs can only refer to localhost
89 89 [255]
90 90
91 91 MSYS changes 'file:' into 'file;'
92 92
93 93 #if no-msys
94 94 $ hg pull -q file:../test # no-msys
95 95 #endif
96 96
97 97 It's tricky to make file:// URLs working on every platform with
98 98 regular shell commands.
99 99
100 100 $ URL=`$PYTHON -c "import os; print 'file://foobar' + ('/' + os.getcwd().replace(os.sep, '/')).replace('//', '/') + '/../test'"`
101 101 $ hg pull -q "$URL"
102 102 abort: file:// URLs can only refer to localhost
103 103 [255]
104 104
105 105 $ URL=`$PYTHON -c "import os; print 'file://localhost' + ('/' + os.getcwd().replace(os.sep, '/')).replace('//', '/') + '/../test'"`
106 106 $ hg pull -q "$URL"
107 107
108 SEC: check for unsafe ssh url
109
110 $ hg pull 'ssh://-oProxyCommand=touch${IFS}owned/path'
111 pulling from ssh://-oProxyCommand%3Dtouch%24%7BIFS%7Downed/path
112 abort: potentially unsafe url: 'ssh://-oProxyCommand=touch${IFS}owned/path'
113 [255]
114 $ hg pull 'ssh://%2DoProxyCommand=touch${IFS}owned/path'
115 pulling from ssh://-oProxyCommand%3Dtouch%24%7BIFS%7Downed/path
116 abort: potentially unsafe url: 'ssh://-oProxyCommand=touch${IFS}owned/path'
117 [255]
118 $ hg pull 'ssh://fakehost|shellcommand/path'
119 pulling from ssh://fakehost%7Cshellcommand/path
120 abort: potentially unsafe url: 'ssh://fakehost|shellcommand/path'
121 [255]
122 $ hg pull 'ssh://fakehost%7Cshellcommand/path'
123 pulling from ssh://fakehost%7Cshellcommand/path
124 abort: potentially unsafe url: 'ssh://fakehost|shellcommand/path'
125 [255]
126
108 127 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now