fix(components): an origin APK without a newer preload output still proves the rest

This commit is contained in:
Kurt Himebauch committed 2026-11-09 13:51:13 -05:00
1 parent ddf3985cb5
commit 9003ed14c0
2 files changed
+26 -1

No files matched your search

+2 -1
View File
@@ -133,7 +133,8 @@ def artifact_bytes(origin, cache):
if len(names) != 1:
raise ValueError('Expected one original APK')
with ZipFile(io.BytesIO(archive.read(names[0]))) as apk:
return {name: apk.read('assets/linuxfs/' + name) for name in FILES}
present = set(apk.namelist())
return {name: apk.read('assets/linuxfs/' + name) for name in FILES if 'assets/linuxfs/' + name in present}
def validate_lock(data):
+24
View File
@@ -150,6 +150,30 @@ class PreloadSnapshotTest(unittest.TestCase):
with self.assertRaisesRegex(ValueError, 'successful main'):
snapshots.artifact_bytes(self.data['origin'], self.root / 'cache')
def test_origin_apk_without_a_newer_output_reads_the_rest(self):
from zipfile import ZipFile
newest = 'libddnatv-hook.so'
apk = io.BytesIO()
with ZipFile(apk, 'w') as z:
for name, value in self.binaries.items():
if name != newest:
z.writestr('assets/linuxfs/' + name, value)
outer = io.BytesIO()
with ZipFile(outer, 'w') as z:
z.writestr('app-release.apk', apk.getvalue())
digest = snapshots.sha(outer.getvalue())
origin = dict(self.data['origin'], artifact_sha256=digest)
build = dict(event='push', head_branch='main', conclusion='success', head_sha=origin['commit'],
path='.github/workflows/build.yml', repository=dict(full_name=snapshots.REPO))
artifact = dict(name='droiddeck-apk', workflow_run=dict(id=origin['run']), digest='sha256:' + digest)
cache = self.root / 'cache'
cache.mkdir()
(cache / (digest + '.zip')).write_bytes(outer.getvalue())
with patch.object(snapshots, 'api', side_effect=[build, artifact]):
content = snapshots.artifact_bytes(origin, cache)
self.assertNotIn(newest, content)
self.assertEqual(set(content), snapshots.FILES - {newest})
def test_corrupt_archive_is_rejected(self):
with self.assertRaisesRegex(ValueError, 'checksum'):
snapshots.unpack(self.content + b'tampered', self.data)