fix: admit bounded receiver telemetry without trusting it
This commit is contained in:
parent
20e923f1a1
commit
6ec4fd7258
@ -47,6 +47,15 @@ class SignedReleaseTests(unittest.TestCase):
|
||||
def test_external_smoke_target_refused(self):
|
||||
with self.assertRaises(Exception):release.response_bytes('https://example.invalid/',64)
|
||||
def test_valid_compressed_release(self):self.assertEqual(self.verify(self.bundle())['product'],'PlotDirector.Website')
|
||||
def test_receiver_telemetry_does_not_change_signed_release(self):
|
||||
bundle=self.bundle();(bundle/'transfer-metrics.json').write_text('{"bytes":0}')
|
||||
self.assertEqual(self.verify(bundle)['product'],'PlotDirector.Website')
|
||||
def test_receiver_telemetry_symlink_refused(self):
|
||||
bundle=self.bundle();(bundle/'transfer-metrics.json').symlink_to(bundle/'authorization.json')
|
||||
with self.assertRaises(Exception):self.verify(bundle)
|
||||
def test_receiver_telemetry_size_bounded(self):
|
||||
bundle=self.bundle();(bundle/'transfer-metrics.json').write_bytes(b'x'*16385)
|
||||
with self.assertRaises(Exception):self.verify(bundle)
|
||||
def test_wrong_product(self):
|
||||
with self.assertRaises(Exception):self.verify(self.bundle(product='PlotLine'))
|
||||
def test_tampered_payload(self):
|
||||
|
||||
@ -46,7 +46,12 @@ def prepare(source,output,release,key,public):
|
||||
print(json.dumps(auth))
|
||||
def verify(source,work,public):
|
||||
source=Path(source).resolve();work=Path(work)
|
||||
require({p.name for p in source.iterdir()}==BUNDLE,'Unexpected bundle members')
|
||||
members={p.name for p in source.iterdir()}
|
||||
require(members in (BUNDLE,BUNDLE|{'transfer-metrics.json'}),'Unexpected bundle members')
|
||||
# The restricted SSH receiver adds bounded, untrusted telemetry. It cannot
|
||||
# authorize payloads and is never interpreted as configuration or a hook.
|
||||
if 'transfer-metrics.json' in members:
|
||||
snapshot(source/'transfer-metrics.json',work/'untrusted-transfer-metrics.json',16384)
|
||||
for name in ('authorization.json','authorization.sig'):snapshot(source/name,work/name,16384)
|
||||
auth=signed_json(work/'authorization.json',work/'authorization.sig',public)
|
||||
require(auth['format']==1 and re.fullmatch('[a-f0-9]{40}',auth['source_commit']),'Invalid authorization')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user