fix: permit verified local APT acquisition with native network denial checks
Rust development slice / linux (push) Failing after 6s
Rust development slice / linux (push) Failing after 6s
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import hashlib
|
||||
import errno
|
||||
import importlib.util
|
||||
import io
|
||||
import json
|
||||
@@ -269,12 +270,34 @@ print('FILTER_LOADED')
|
||||
def test_exact_argv_config_and_fixed_hook(self):
|
||||
tx = apt.ResolvedAptTransaction.parse(transaction())
|
||||
argv = apt.apt_argv(tx)
|
||||
self.assertIn('--no-download', argv)
|
||||
self.assertNotIn('--no-download', argv) # real v3 otherwise reports **ERROR**
|
||||
self.assertIn('--no-remove', argv)
|
||||
self.assertNotIn('update', argv)
|
||||
self.assertEqual(argv[-1], tx.packages[0].archive_path)
|
||||
self.assertEqual((ROOT / 'tools/apt-transaction/hook').read_bytes(), apt.hook_script())
|
||||
self.assertIn(b'Dir::Etc::parts', apt.apt_config())
|
||||
self.assertIn(b'APT::Get::Download "true";', apt.apt_config())
|
||||
|
||||
def test_ip_socket_denials_are_required_for_both_families(self):
|
||||
with patch.object(apt.socket, 'socket', side_effect=OSError(errno.EAFNOSUPPORT, 'synthetic')) as make:
|
||||
apt.verify_no_ip_sockets()
|
||||
self.assertEqual([call.args[0] for call in make.call_args_list], [apt.socket.AF_INET, apt.socket.AF_INET6])
|
||||
|
||||
def test_permitted_ipv4_socket_closes_and_vetoes(self):
|
||||
closed=[];candidate=SimpleNamespace(close=lambda:closed.append(True))
|
||||
with patch.object(apt.socket, 'socket', return_value=candidate):
|
||||
with self.assertRaisesRegex(apt.Veto, 'SANDBOX_IP_SOCKET_ALLOWED'):apt.verify_no_ip_sockets()
|
||||
self.assertEqual(closed,[True])
|
||||
|
||||
def test_permitted_ipv6_cannot_hide_behind_denied_ipv4(self):
|
||||
closed=[];candidate=SimpleNamespace(close=lambda:closed.append(True))
|
||||
with patch.object(apt.socket, 'socket', side_effect=[OSError(errno.EPERM,'synthetic'),candidate]):
|
||||
with self.assertRaisesRegex(apt.Veto, 'SANDBOX_IP_SOCKET_ALLOWED'):apt.verify_no_ip_sockets()
|
||||
self.assertEqual(closed,[True])
|
||||
|
||||
def test_resource_exhaustion_is_not_a_network_denial_proof(self):
|
||||
with patch.object(apt.socket, 'socket', side_effect=OSError(errno.EMFILE,'synthetic')):
|
||||
with self.assertRaisesRegex(apt.Veto, 'SANDBOX_IP_SOCKET_CHECK'):apt.verify_no_ip_sockets()
|
||||
|
||||
|
||||
class FixtureTests(unittest.TestCase):
|
||||
|
||||
Reference in New Issue
Block a user