Read all Git tree pages and keep migration snapshot compatible with old bootstraps
This commit is contained in:
parent
743048ec60
commit
cb8b4d0ecc
|
|
@ -635,3 +635,16 @@ journalctl -u iomatex-rt-webui.service -n 80 --no-pager
|
||||||
- надо переустановить только одну часть Edge;
|
- надо переустановить только одну часть Edge;
|
||||||
- надо решить, можно ли ставить стадию поверх уже рабочего устройства;
|
- надо решить, можно ли ставить стадию поверх уже рабочего устройства;
|
||||||
- надо подробно разобраться с `stage_reverse_tunnels`.
|
- надо подробно разобраться с `stage_reverse_tunnels`.
|
||||||
|
|
||||||
|
|
||||||
|
## Обновление Console 3.1.42 и stage_itscreen 1.0.41
|
||||||
|
|
||||||
|
### Исправления доставки обновлений
|
||||||
|
|
||||||
|
- Distinguish Cloudflare HTTP 403 / 1010 client-signature rejection from Git credential failures; do not expose HTTP response bodies or secrets.
|
||||||
|
- Publish `stage_itscreen` 1.0.41: the Debian updater reads `latest-iomatex.json`, whose binary URL matches its strict `git.iomatex.com` allowlist. Legacy `latest.json` remains available for old-domain clients.
|
||||||
|
- Preserve checksum/size/embedded-version checks, redirect refusal, installer lock and rollback. No client binary is replaced in the public repository.
|
||||||
|
|
||||||
|
Validation: offline delivery/stage-version tests, Debian updater tests, Console stage-update API/UI contracts, and the active UAE Edge diagnostic recorded separately.
|
||||||
|
|
||||||
|
Переходный снимок оставлен в пределах 1000 Git tree entries, чтобы его мог загрузить старый bootstrap без пагинации. Новый bootstrap загружает все страницы дерева одного commit и проверяет их полноту, отсутствие повторов и неизменность commit. Не добавляйте новые файлы в этот переходный снимок без проверки доступа старого загрузчика. Старую Console, которая показывает Cloudflare 1010, сначала перезапустите: это активирует уже обновлённый HTTP User-Agent; пароль Git менять не требуется, если аутентифицированный запрос возвращает HTTP 200.
|
||||||
|
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
# Console 3.1.42 — Git diagnostics and Debian update channel
|
|
||||||
|
|
||||||
- Distinguish Cloudflare HTTP 403 / 1010 client-signature rejection from Git credential failures; do not expose HTTP response bodies or secrets.
|
|
||||||
- Publish `stage_itscreen` 1.0.41: the Debian updater reads `latest-iomatex.json`, whose binary URL matches its strict `git.iomatex.com` allowlist. Legacy `latest.json` remains available for old-domain clients.
|
|
||||||
- Preserve checksum/size/embedded-version checks, redirect refusal, installer lock and rollback. No client binary is replaced in the public repository.
|
|
||||||
|
|
||||||
Validation: offline delivery/stage-version tests, Debian updater tests, Console stage-update API/UI contracts, and the active UAE Edge diagnostic recorded separately.
|
|
||||||
|
|
@ -283,6 +283,44 @@ def recovery_gate(repo, branch, commit, auth, files, stages, job=None):
|
||||||
raise RecoveryPending('Offline userdata recovery queued; update is pending, not complete')
|
raise RecoveryPending('Offline userdata recovery queued; update is pending, not complete')
|
||||||
|
|
||||||
|
|
||||||
|
def repository_tree(repo, commit, auth):
|
||||||
|
"""Read every Gitea tree page from one immutable commit before changing files."""
|
||||||
|
endpoint = 'git/trees/' + commit + '?recursive=true'
|
||||||
|
with open_git(repo, endpoint, auth) as response:
|
||||||
|
first = json.load(response)
|
||||||
|
entries = first.get('tree')
|
||||||
|
if not isinstance(entries, list):
|
||||||
|
raise ValueError('Invalid Git repository tree')
|
||||||
|
if not first.get('truncated'):
|
||||||
|
return entries
|
||||||
|
total = first.get('total_count')
|
||||||
|
if type(total) is not int or not len(entries) or not len(entries) <= total <= 100000:
|
||||||
|
raise ValueError('Git returned an incomplete repository tree')
|
||||||
|
entries = list(entries)
|
||||||
|
seen = {item['path'] for item in entries}
|
||||||
|
if len(seen) != len(entries):
|
||||||
|
raise ValueError('Duplicate Git tree members')
|
||||||
|
page = 1
|
||||||
|
while len(entries) < total:
|
||||||
|
page += 1
|
||||||
|
if page > 1000:
|
||||||
|
raise ValueError('Git tree pagination limit exceeded')
|
||||||
|
with open_git(repo, endpoint + '&page=' + str(page), auth) as response:
|
||||||
|
part = json.load(response)
|
||||||
|
chunk = part.get('tree')
|
||||||
|
if (not isinstance(chunk, list) or not chunk or part.get('total_count') != total
|
||||||
|
or part.get('sha') != first.get('sha') or part.get('page', page) != page):
|
||||||
|
raise ValueError('Git returned inconsistent repository tree pages')
|
||||||
|
for item in chunk:
|
||||||
|
if item['path'] in seen:
|
||||||
|
raise ValueError('Duplicate Git tree members')
|
||||||
|
seen.add(item['path'])
|
||||||
|
entries.extend(chunk)
|
||||||
|
if len(entries) > total:
|
||||||
|
raise ValueError('Git tree exceeds declared size')
|
||||||
|
return entries
|
||||||
|
|
||||||
|
|
||||||
def bootstrap(url, branch, checkout, commit=None, recovery_stages=None, recovery_job=None, preserve_local_changes=False):
|
def bootstrap(url, branch, checkout, commit=None, recovery_stages=None, recovery_job=None, preserve_local_changes=False):
|
||||||
platform_check()
|
platform_check()
|
||||||
repo = repo_name(url)
|
repo = repo_name(url)
|
||||||
|
|
@ -296,12 +334,9 @@ def bootstrap(url, branch, checkout, commit=None, recovery_stages=None, recovery
|
||||||
commit = json.load(r)['commit']['id']
|
commit = json.load(r)['commit']['id']
|
||||||
if not re.fullmatch('[a-f0-9]{40}', commit):
|
if not re.fullmatch('[a-f0-9]{40}', commit):
|
||||||
raise ValueError('Invalid pinned commit')
|
raise ValueError('Invalid pinned commit')
|
||||||
with open_git(repo, 'git/trees/' + commit + '?recursive=true', auth) as r:
|
tree = repository_tree(repo, commit, auth)
|
||||||
tree = json.load(r)
|
|
||||||
if tree.get('truncated'):
|
|
||||||
raise ValueError('Git returned an incomplete repository tree')
|
|
||||||
files = []
|
files = []
|
||||||
for item in tree['tree']:
|
for item in tree:
|
||||||
path = safe_path(item['path'])
|
path = safe_path(item['path'])
|
||||||
if item['type'] == 'tree' or is_payload(path):
|
if item['type'] == 'tree' or is_payload(path):
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,21 @@ sys.path.insert(0, str(Path(__file__).parent))
|
||||||
import git_delivery as d
|
import git_delivery as d
|
||||||
|
|
||||||
class DeliveryTest(unittest.TestCase):
|
class DeliveryTest(unittest.TestCase):
|
||||||
|
def test_paginated_tree_is_complete_and_pinned_before_bootstrap(self):
|
||||||
|
commit = 'a' * 40
|
||||||
|
first = {'sha':commit, 'truncated':True, 'total_count':3, 'page':1,
|
||||||
|
'tree':[{'path':'a'}, {'path':'b'}]}
|
||||||
|
second = {**first, 'page':2, 'tree':[{'path':'c'}]}
|
||||||
|
with patch.object(d, 'open_git', side_effect=[io.StringIO(json.dumps(first)), io.StringIO(json.dumps(second))]) as request:
|
||||||
|
self.assertEqual(['a','b','c'], [v['path'] for v in d.repository_tree('An-J/Iomatex_OS', commit, {})])
|
||||||
|
self.assertEqual('git/trees/'+commit+'?recursive=true&page=2', request.call_args.args[1])
|
||||||
|
for bad in [{**second, 'tree':[]}, {**second, 'sha':'b'*40},
|
||||||
|
{**second, 'tree':[{'path':'a'}]}, {**second, 'total_count':4},
|
||||||
|
{**second, 'page':1}]:
|
||||||
|
with self.subTest(page=bad), patch.object(d, 'open_git', side_effect=[io.StringIO(json.dumps(first)), io.StringIO(json.dumps(bad))]):
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
d.repository_tree('An-J/Iomatex_OS', commit, {})
|
||||||
|
|
||||||
def test_only_trusted_git_aliases_receive_credentials(self):
|
def test_only_trusted_git_aliases_receive_credentials(self):
|
||||||
for host in d.ALLOWED_HOSTS:
|
for host in d.ALLOWED_HOSTS:
|
||||||
self.assertEqual('An-J/Iomatex_OS', d.repo_name('https://' + host + '/An-J/Iomatex_OS.git'))
|
self.assertEqual('An-J/Iomatex_OS', d.repo_name('https://' + host + '/An-J/Iomatex_OS.git'))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue