def _getImportDataForJobID(self, job_id): job = self._getJob(job_id) target = job.code_import.target return { 'arguments': job.makeWorkerArguments(), 'target_url': canonical_url(target), 'log_file_name': '%s.log' % (target.unique_name[1:].replace('/', '-')), 'blacklisted_hostnames': get_blacklisted_hostnames(), }
def checkOneURL(self, url): """See `BranchOpenPolicy.checkOneURL`. We refuse to mirror from Launchpad or a ssh-like or file URL. """ try: uri = URI(url) except InvalidURIError: raise BadUrl(url) launchpad_domain = config.vhost.mainsite.hostname if uri.underDomain(launchpad_domain): raise BadUrl(url) for hostname in get_blacklisted_hostnames(): if uri.underDomain(hostname): raise BadUrl(url) if uri.scheme not in self.allowed_schemes: raise BadUrl(url)
def checkOneURL(self, url): """See `BranchOpenPolicy.checkOneURL`. We refuse to mirror from Launchpad or a ssh-like or file URL. """ # Avoid circular import from lp.code.interfaces.branch import get_blacklisted_hostnames uri = URI(url) launchpad_domain = config.vhost.mainsite.hostname if uri.underDomain(launchpad_domain): raise BadUrlLaunchpad(url) for hostname in get_blacklisted_hostnames(): if uri.underDomain(hostname): raise BadUrl(url) if uri.scheme in ['sftp', 'bzr+ssh']: raise BadUrlSsh(url) elif uri.scheme not in ['http', 'https']: raise BadUrlScheme(uri.scheme, url)
def test_get_blacklisted_hostnames_empty(self): self.assertEqual([], get_blacklisted_hostnames())
def test_get_blacklisted_hostnames(self): self.pushConfig('codehosting', blacklisted_hostnames='localhost,127.0.0.1') self.assertEqual(['localhost', '127.0.0.1'], get_blacklisted_hostnames())
def test_get_blacklisted_hostnames(self): self.pushConfig( 'codehosting', blacklisted_hostnames='localhost,127.0.0.1') self.assertEqual( ['localhost', '127.0.0.1'], get_blacklisted_hostnames())