@@ -67,7 +67,7 @@ def initialize(info = {})
67
67
{
68
68
'PayloadType' => 'cmd cmd_bash' ,
69
69
'RequiredCmd' => 'generic bash-tcp perl bash'
70
- } ,
70
+ }
71
71
}
72
72
}
73
73
] ,
@@ -103,7 +103,7 @@ def setup
103
103
mercurial : { files : { } , trigger : nil }
104
104
}
105
105
if git_uri . blank? && mercurial_uri . blank?
106
- fail ArgumentError , 'Must specify at least one non-blank GIT_URI or MERCURIAL_URI'
106
+ fail_with ( Exploit :: Failure :: BadConfig , 'Must specify at least one non-blank GIT_URI or MERCURIAL_URI' )
107
107
end
108
108
setup_git unless git_uri . blank?
109
109
setup_mercurial unless mercurial_uri . blank?
@@ -113,9 +113,13 @@ def setup
113
113
114
114
def setup_git
115
115
# URI must start with a /
116
- fail ArgumentError , 'GIT_URI must start with a /' unless git_uri =~ /^\/ /
116
+ unless git_uri =~ /^\/ /
117
+ fail_with ( Exploit ::Failure ::BadConfig , 'GIT_URI must start with a /' )
118
+ end
117
119
# sanity check the malicious hook:
118
- fail ArgumentError , 'GIT_HOOK must not be blank' if datastore [ 'GIT_HOOK' ] . blank?
120
+ if datastore [ 'GIT_HOOK' ] . blank?
121
+ fail_with ( Exploit ::Failure ::BadConfig , 'GIT_HOOK must not be blank' )
122
+ end
119
123
120
124
# This builds a fake git repository using the knowledge from:
121
125
# http://schacon.github.io/gitbook/7_how_git_stores_objects.html
@@ -191,9 +195,13 @@ def setup_git
191
195
192
196
def setup_mercurial
193
197
# URI must start with a /
194
- fail ArgumentError , 'MERCURIAL_URI must start with a /' unless mercurial_uri =~ /^\/ /
195
- # sanity check the malicious hook:
196
- fail ArgumentError , 'MERCURIAL_HOOK must not be blank' if datastore [ 'MERCURIAL_HOOK' ] . blank?
198
+ unless mercurial_uri =~ /^\/ /
199
+ fail_with ( Exploit ::Failure ::BadConfig , 'MERCURIAL_URI must start with a /' )
200
+ end
201
+ # sanity check the malicious hook
202
+ if datastore [ 'MERCURIAL_HOOK' ] . blank?
203
+ fail_with ( Exploit ::Failure ::BadConfig , 'MERCURIAL_HOOK must not be blank' )
204
+ end
197
205
# we fake the Mercurial HTTP protocol such that we are compliant as possible but
198
206
# also as simple as possible so that we don't have to support all of the protocol
199
207
# complexities. Taken from:
0 commit comments