Identify OS updater requests for the new Git proxy

This commit is contained in:
Andrei Smaliak 2026-10-29 15:46:33 +01:00
parent 1d10037325
commit dd52cbe9a3
5 changed files with 5 additions and 2 deletions

View File

@ -3,3 +3,4 @@
- Install shared Git delivery with git.iomatex.com as its canonical HTTPS host.
- Normalize legacy saved hosts in stage checks and package downloads; retain exact-host trust, TLS verification, pinned commits and checksums.
- Bootstrap defaults to git.iomatex.com; legacy installer URLs and virtual APT paths remain accepted.
- Identify bootstrap and package requests as IomatexOS-Updater/1.0; avoid the new proxy rejecting the default Python user agent with Cloudflare 1010.

View File

@ -56,7 +56,7 @@ repo = parsed.path.strip('/').removesuffix('.git')
class NoRedirect(urllib.request.HTTPRedirectHandler):
def redirect_request(self, *args, **kwargs):
raise RuntimeError('Git download redirect refused')
headers = {'Authorization': 'Basic ' + base64.b64encode((os.environ['IOMATEX_GIT_USERNAME'] + ':' + os.environ['IOMATEX_GIT_PASSWORD']).encode()).decode()}
headers = {'User-Agent': 'IomatexOS-Updater/1.0', 'Authorization': 'Basic ' + base64.b64encode((os.environ['IOMATEX_GIT_USERNAME'] + ':' + os.environ['IOMATEX_GIT_PASSWORD']).encode()).decode()}
opener = urllib.request.build_opener(NoRedirect)
hosts = [parsed.netloc] + [h for h in ('git.it-screen.com', 'git.iomatex.com') if h != parsed.netloc]
commit = None

View File

@ -68,7 +68,7 @@ def auth_from_env():
def open_git(repo, endpoint, auth, timeout=120):
url = 'https://' + git_host(auth.get('host', HOST)) + '/api/v1/repos/' + repo + '/' + endpoint
token = base64.b64encode((auth['username'] + ':' + auth['password']).encode()).decode()
req = urllib.request.Request(url, headers={'Authorization': 'Basic ' + token})
req = urllib.request.Request(url, headers={'Authorization': 'Basic ' + token, 'User-Agent': 'IomatexOS-Updater/1.0'})
return urllib.request.build_opener(NoRedirect).open(req, timeout=timeout)
def raw_endpoint(path, commit):

View File

@ -39,6 +39,7 @@ class BootstrapFallbackTest(unittest.TestCase):
def test_explicit_alternate_is_tried_first(self):
_, opener = self.run_bootstrap([io.BytesIO(BRANCH), io.BytesIO(b'loader')], 'git.iomatex.com')
self.assertIn('git.iomatex.com', opener.open.call_args_list[0].args[0].full_url)
self.assertEqual('IomatexOS-Updater/1.0', opener.open.call_args_list[0].args[0].get_header('User-agent'))
def test_auth_and_tls_fail_without_switch(self):
for error in [HTTPError('url', 401, 'Unauthorized', {}, None), URLError(ssl.SSLCertVerificationError('invalid certificate'))]:

View File

@ -17,6 +17,7 @@ class DeliveryTest(unittest.TestCase):
with patch.object(d.urllib.request, 'build_opener') as opener:
d.open_git('An-J/Iomatex_OS', 'branches/ci-cd', {'username': 'u', 'password': 'p', 'host': host})
request = opener.return_value.open.call_args.args[0]
self.assertEqual('IomatexOS-Updater/1.0', request.get_header('User-agent'))
self.assertEqual('https://git.iomatex.com/api/v1/repos/An-J/Iomatex_OS/branches/ci-cd', request.full_url)
for host in ['evil.example', 'git.iomatex.com.evil', 'user@git.iomatex.com', 'git.iomatex.com:443']:
with self.assertRaises(ValueError):