335 lines
22 KiB
Python
335 lines
22 KiB
Python
#!/usr/bin/env python3
|
|
"""Frozen ten-worker list, executing exactly two process-census guards only; no Apply.
|
|
|
|
Prepare copies the independently reviewed snapshot locally. Execute is one
|
|
root-only Cloud-VM fixture run. After any lost reply read the original case;
|
|
never execute it again or substitute another binary/source generation.
|
|
"""
|
|
import argparse
|
|
import base64
|
|
import hashlib
|
|
import inspect
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
import stat
|
|
import uuid
|
|
|
|
import windows_msi_runtime_acceptance as support
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
ACCESS_ROOT = ROOT.parent / 'rust-discovery'
|
|
QUALIFICATION = ROOT / 'devstate/agent-updater-worker/reader-census-final-da31051b-269f-4fb5-947d-94c8ad162c2a'
|
|
STATE = ROOT / 'devstate/updater-reader-census-linux'
|
|
PROFILE = 'rmm.updater.two-process-census-guards.v1'
|
|
RECEIPT_SHA = '9020992e888d0b22e71db88cab78f255e273be2a4a7856d43616b387c36c74ae'
|
|
INPUTS_SHA = '382714b09349e448441345abbac6d99c0d523e98bdabaa78290b400768bac8f7'
|
|
BINARY_SHA = 'e83fd334b005d81ac917389de2a1c7486bea3f62ae45d77bccbd331e131e4304'
|
|
BINARY_BYTES = 7888096
|
|
CENSUS_SOURCES = {'crates/updater-worker/src/census.rs': {'bytes': 17766, 'sha256': '5bee7f835c3b3c1f7e3a6afeeb1dc1fde780f1a6ca0d09a1bc85d897249e053c'}, 'crates/updater-worker/src/census_process.rs': {'bytes': 25024, 'sha256': 'f94b3032cee983fb01bfeb97a1cfc497fddcfd1e6f00e055d87269cc3f5dad5e'}, 'crates/updater-worker/src/reader_registry.rs': {'bytes': 29064, 'sha256': 'fc013cde406f4dac96a35df3852738b0ff84d912c4eeba401609b0d2b239d1b1'}}
|
|
ALL_TESTS = ['agent_startup::tests::existing_agent_lock_blocks_aliases_and_rejects_samebyte_inode_substitution', 'census_process::tests::actual_proc_probe_detects_existing_descriptors_and_mapped_inode_without_exporting_paths', 'census_process::tests::private_thread_fd_table_cannot_hide_a_reader_from_the_group_probe', 'history::tests::completed_history_rejects_file_only_rollback_forks_and_tampered_activation_without_writes', 'history::tests::public_record_builder_binds_actual_original_key_and_exact_health_head', 'reader_registry::tests::timer_without_process_interface_is_typed_but_missing_service_pid_or_pending_job_denies', 'record::tests::same_byte_inode_substitution_and_foreign_current_block_without_resume', 'record::tests::separate_record_renames_preserve_original_inode_and_both_raw_archives', 'retained::tests::reopen_preserves_original_stamps_and_rejects_replaced_state_without_reading_keys', 'trust::tests::separately_signed_baseline_at_floor_is_historical_only_and_candidate_stays_strict']
|
|
TESTS = ['census_process::tests::actual_proc_probe_detects_existing_descriptors_and_mapped_inode_without_exporting_paths', 'census_process::tests::private_thread_fd_table_cannot_hide_a_reader_from_the_group_probe']
|
|
TEST_FILTER = 'census_process::tests::'
|
|
AGENT_SHA = '0a7ad6eefaefda79ee80b6a41b2df904e9e7f50ae6ebeed01b98c25b6ce5c06f'
|
|
HELPER_SHA = '79442727c3ba31cda02a8bc0e67481f14db9f39fc07520a880a90b64f10f1eaf'
|
|
|
|
|
|
def sha(raw):
|
|
return hashlib.sha256(raw).hexdigest()
|
|
|
|
|
|
def save_local(path, value):
|
|
support.save(path, value)
|
|
fd = os.open(path.parent, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW)
|
|
try:
|
|
os.fsync(fd)
|
|
finally:
|
|
os.close(fd)
|
|
|
|
|
|
def copy_exact(source, destination, digest, size):
|
|
metadata = source.lstat()
|
|
support.require(stat.S_ISREG(metadata.st_mode) and metadata.st_nlink == 1
|
|
and metadata.st_uid in (0, os.getuid()) and not metadata.st_mode & 0o002
|
|
and metadata.st_size == size and size <= 8 * 1024 * 1024, 'bounded regular frozen input')
|
|
raw = source.read_bytes()
|
|
support.require(sha(raw) == digest, 'frozen snapshot input hash')
|
|
destination.parent.mkdir(mode=0o700, parents=True, exist_ok=True)
|
|
support.private(destination.parent, True)
|
|
fd = os.open(destination, os.O_CREAT | os.O_EXCL | os.O_NOFOLLOW | os.O_WRONLY, 0o600)
|
|
with os.fdopen(fd, 'wb') as stream:
|
|
stream.write(raw); stream.flush(); os.fsync(stream.fileno())
|
|
fd = os.open(destination.parent, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW)
|
|
try:
|
|
os.fsync(fd)
|
|
finally:
|
|
os.close(fd)
|
|
|
|
|
|
def verify_case(folder):
|
|
value = support.load(folder / 'manifest.json')
|
|
support.require(value['profile'] == PROFILE and value['tests'] == TESTS and value['all_tests'] == ALL_TESTS
|
|
and value['test_filter'] == TEST_FILTER
|
|
and value['runner_sha256'] == sha(Path(__file__).read_bytes())
|
|
and value['receipt_sha256'] == RECEIPT_SHA and value['binary_sha256'] == BINARY_SHA
|
|
and value['binary_bytes'] == BINARY_BYTES, 'same original reviewed manifest')
|
|
support.require(sha((folder / 'receipt.json').read_bytes()) == RECEIPT_SHA
|
|
and sha((folder / 'inputs.json').read_bytes()) == INPUTS_SHA, 'original qualification provenance')
|
|
source = support.load(folder / 'inputs.json')
|
|
support.require(len(source) == 71 and source == value['source_files'], 'exact frozen 71 qualification inputs')
|
|
for item in source:
|
|
path = Path(item['path'])
|
|
support.require(not path.is_absolute() and '..' not in path.parts, 'fixed snapshot relative path')
|
|
file = folder / 'source' / path
|
|
support.private(file)
|
|
support.require(file.stat().st_size == item['bytes'] and sha(file.read_bytes()) == item['sha256'], 'retained source freeze')
|
|
support.require({item['path']: dict(bytes=item['bytes'], sha256=item['sha256']) for item in source
|
|
if item['path'] in CENSUS_SOURCES} == CENSUS_SOURCES, 'exact census and registry source snapshot')
|
|
binary = folder / 'worker-census-tests'; support.private(binary)
|
|
support.require(binary.stat().st_size == BINARY_BYTES and sha(binary.read_bytes()) == BINARY_SHA, 'original qualified test bytes')
|
|
for path, digest in value['transport_sources'].items():
|
|
support.require(sha((ROOT / path).read_bytes()) == digest, 'original strict transport source')
|
|
return value
|
|
|
|
|
|
def remote(p):
|
|
import base64
|
|
import hashlib
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
import selectors
|
|
import signal
|
|
import stat
|
|
import subprocess
|
|
import time
|
|
import uuid
|
|
|
|
def require(ok, message):
|
|
if not ok:
|
|
raise RuntimeError(message)
|
|
|
|
def enc(value):
|
|
return json.dumps(value, sort_keys=True, separators=(',', ':')).encode()
|
|
|
|
def create(path, raw, mode=0o600):
|
|
fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_EXCL | os.O_NOFOLLOW, mode)
|
|
with os.fdopen(fd, 'wb') as stream:
|
|
stream.write(raw); stream.flush(); os.fsync(stream.fileno())
|
|
fd = os.open(path.parent, os.O_DIRECTORY | os.O_RDONLY | os.O_NOFOLLOW)
|
|
try:
|
|
os.fsync(fd)
|
|
finally:
|
|
os.close(fd)
|
|
|
|
def run(args, timeout=20):
|
|
# Keep the owned group leader unreaped until its entire group has been
|
|
# cleaned up. Its PID therefore cannot be recycled before killpg.
|
|
child = subprocess.Popen(args, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE,
|
|
stderr=subprocess.PIPE, start_new_session=True,
|
|
env={'PATH': '/usr/bin:/bin', 'LC_ALL': 'C', 'HOME': '/nonexistent'})
|
|
selector = selectors.DefaultSelector()
|
|
buffers = {'stdout': bytearray(), 'stderr': bytearray()}
|
|
deadline = time.monotonic() + timeout
|
|
try:
|
|
for stream, name in ((child.stdout, 'stdout'), (child.stderr, 'stderr')):
|
|
os.set_blocking(stream.fileno(), False); selector.register(stream, selectors.EVENT_READ, name)
|
|
while True:
|
|
require(time.monotonic() < deadline, 'owned native command timeout; read original case only')
|
|
for key, _ in selector.select(0.02):
|
|
raw = os.read(key.fileobj.fileno(), 4096)
|
|
if raw:
|
|
buffers[key.data].extend(raw)
|
|
require(len(buffers[key.data]) <= 65536, 'bounded native output')
|
|
else:
|
|
selector.unregister(key.fileobj)
|
|
ended = os.waitid(os.P_PID, child.pid, os.WEXITED | os.WNOHANG | os.WNOWAIT)
|
|
if ended is not None:
|
|
# Child remains a zombie until finally: no PID/group reuse.
|
|
os.killpg(child.pid, signal.SIGKILL)
|
|
for key in list(selector.get_map().values()):
|
|
while True:
|
|
try:
|
|
raw = os.read(key.fileobj.fileno(), 4096)
|
|
except BlockingIOError:
|
|
break
|
|
if not raw:
|
|
break
|
|
buffers[key.data].extend(raw)
|
|
require(len(buffers[key.data]) <= 65536, 'bounded native output')
|
|
code = ended.si_status if ended.si_code == os.CLD_EXITED else -ended.si_status
|
|
return code, bytes(buffers['stdout']), bytes(buffers['stderr'])
|
|
finally:
|
|
os.killpg(child.pid, signal.SIGKILL)
|
|
child.wait()
|
|
selector.close(); child.stdout.close(); child.stderr.close()
|
|
|
|
def metadata_identity(value):
|
|
return (value.st_dev, value.st_ino, value.st_uid, value.st_gid, value.st_mode,
|
|
value.st_nlink, value.st_size, value.st_mtime_ns, value.st_ctime_ns)
|
|
|
|
def hashed(path, maximum, process_image=False):
|
|
fd = os.open(path, os.O_RDONLY | os.O_CLOEXEC | (0 if process_image else os.O_NOFOLLOW))
|
|
with os.fdopen(fd, 'rb') as stream:
|
|
before = os.fstat(stream.fileno()); require(stat.S_ISREG(before.st_mode) and before.st_size <= maximum, 'bounded witness file')
|
|
digest = hashlib.sha256(); total = 0
|
|
while True:
|
|
raw = stream.read(32768)
|
|
if not raw:
|
|
break
|
|
total += len(raw); require(total <= maximum, 'bounded witness hash'); digest.update(raw)
|
|
after = os.fstat(stream.fileno())
|
|
require(metadata_identity(before) == metadata_identity(after) and total == before.st_size, 'stable witness hash')
|
|
return before, digest.hexdigest()
|
|
|
|
def witness():
|
|
out = {'boot_id': Path('/proc/sys/kernel/random/boot_id').read_text().strip(), 'services': {}, 'files': {}}
|
|
release = dict(line.split('=', 1) for line in Path('/etc/os-release').read_text().splitlines() if '=' in line)
|
|
require(release.get('ID', '').strip('"') == 'ubuntu' and release.get('VERSION_ID', '').strip('"') == '24.04', 'fixed native Ubuntu24.04')
|
|
out['os'] = {'id': 'ubuntu', 'version': '24.04', 'machine': os.uname().machine, 'kernel': os.uname().release}
|
|
for name, uid, binary in (
|
|
('rmm-agent-remote.service', 993, p['agent_sha256']),
|
|
('rmm-helper-cloud.service', 0, p['helper_sha256']),
|
|
('rmm-full-maintenance-helper.service', 0, p['helper_sha256'])):
|
|
code, stdout, _ = run(['/usr/bin/systemctl', 'show', name, '-p', 'ActiveState', '-p', 'MainPID', '-p', 'UnitFileState', '-p', 'InvocationID'])
|
|
require(code == 0, 'existing service read')
|
|
service = dict(line.split('=', 1) for line in stdout.decode().splitlines())
|
|
pid = int(service['MainPID']); require(service['ActiveState'] == 'active' and pid > 1, 'three existing services active')
|
|
proc = Path('/proc', str(pid)); birth = (proc / 'stat').read_text().rsplit(') ', 1)[1].split()[19]
|
|
ids = {line.split(':')[0]: line.split()[1:] for line in (proc / 'status').read_text().splitlines() if line.startswith(('Uid:', 'Gid:'))}
|
|
metadata, image = hashed(proc / 'exe', 256 * 1024 * 1024, process_image=True)
|
|
current = (proc / 'exe').stat()
|
|
require(ids['Uid'] == [str(uid)] * 4 and ids['Gid'] == ['984'] * 4 and image == binary
|
|
and (metadata.st_dev, metadata.st_ino) == (current.st_dev, current.st_ino)
|
|
and (proc / 'stat').read_text().rsplit(') ', 1)[1].split()[19] == birth, 'current generation/account/image')
|
|
out['services'][name] = dict(service, birth=birth, image=image, ids=ids)
|
|
code, stdout, _ = run(['/usr/bin/systemctl', 'show', 'rmm-apt-helper.service', '-p', 'ActiveState', '-p', 'UnitFileState'])
|
|
apt = dict(line.split('=', 1) for line in stdout.decode().splitlines())
|
|
require(code == 0 and apt == {'ActiveState': 'inactive', 'UnitFileState': 'disabled'}, 'APT remains closed')
|
|
out['apt'] = apt
|
|
for name in ('/etc/rmm-remote/helper-general.json', '/etc/rmm-remote/helper-full-maintenance.json',
|
|
'/etc/rmm-remote/full-maintenance-helper-proof.json', '/etc/systemd/system/rmm-full-maintenance-helper.service'):
|
|
path = Path(name); metadata = path.lstat()
|
|
require(not path.is_symlink() and stat.S_ISREG(metadata.st_mode) and metadata.st_uid == 0
|
|
and not metadata.st_mode & 0o022 and metadata.st_nlink == 1, 'protected known control')
|
|
current, digest = hashed(path, 65536)
|
|
require(metadata_identity(current) == metadata_identity(metadata), 'same known control file')
|
|
out['files'][name] = [metadata.st_dev, metadata.st_ino, metadata.st_uid, metadata.st_gid, metadata.st_mode,
|
|
metadata.st_size, metadata.st_mtime_ns, metadata.st_ctime_ns, digest]
|
|
for name in ('/var/lib/rmm-helper/consumption.sqlite', '/var/lib/rmm-helper/executor.lock',
|
|
'/var/lib/rmm-agent-remote/journal.sqlite', '/var/lib/rmm-agent-remote/consumption.sqlite',
|
|
'/var/lib/rmm-agent-remote/agent.lock'):
|
|
path = Path(name); metadata = path.lstat()
|
|
require(not path.is_symlink() and stat.S_ISREG(metadata.st_mode) and metadata.st_nlink == 1, 'existing state identity')
|
|
out['files'][name] = [metadata.st_dev, metadata.st_ino, metadata.st_uid, metadata.st_gid, metadata.st_mode]
|
|
return out
|
|
|
|
require(os.geteuid() == 0 and os.uname().machine == 'x86_64', 'fixed Cloud Linux root process-census fixtures')
|
|
require(p['profile'] == 'rmm.updater.two-process-census-guards.v1'
|
|
and p['binary_sha256'] == 'e83fd334b005d81ac917389de2a1c7486bea3f62ae45d77bccbd331e131e4304'
|
|
and p['test_filter'] == 'census_process::tests::'
|
|
and len(p['all_tests']) == 10 and len(p['tests']) == 2
|
|
and [name for name in p['all_tests'] if name.startswith(p['test_filter'])] == p['tests'],
|
|
'closed two-test census scope before remote case creation')
|
|
ident = str(uuid.UUID(p['id'])); require(ident == p['id'], 'canonical original case')
|
|
folder = Path('/var/tmp') / ('rmm-updater-reader-census-linux-' + ident)
|
|
if p['action'] == 'read':
|
|
metadata = folder.lstat()
|
|
require(stat.S_ISDIR(metadata.st_mode) and not folder.is_symlink() and metadata.st_uid == 0
|
|
and stat.S_IMODE(metadata.st_mode) == 0o700, 'own original case only')
|
|
intent = json.loads((folder / 'intent.json').read_bytes())
|
|
require(all(intent.get(key) == value for key,value in p.items() if key != 'action'), 'same original read binding')
|
|
result = folder / 'result.json'
|
|
return {'read_only': True, 'id': ident, 'entered': (folder / 'entered.json').exists(),
|
|
'result': json.loads(result.read_bytes()) if result.exists() else None, 'current_witness': witness()}
|
|
require(p['action'] == 'execute', 'one fixed process-census unit action')
|
|
os.umask(0o077); folder.mkdir(mode=0o700)
|
|
create(folder / 'intent.json', enc({key: value for key, value in p.items() if key != 'binary_b64'}))
|
|
require(len(p['binary_b64']) == 10517464, 'bounded binary transfer')
|
|
raw = base64.b64decode(p['binary_b64'], validate=True)
|
|
require(len(raw) == 7888096 and hashlib.sha256(raw).hexdigest() == p['binary_sha256'], 'fixed worker test binary; only the closed census filter may run')
|
|
binary = folder / 'worker-census-tests'; create(binary, raw, 0o700)
|
|
before = witness(); create(folder / 'before.json', enc(before))
|
|
command = ['/usr/bin/setpriv', '--reuid=0', '--regid=0', '--clear-groups', '--no-new-privs', str(binary)]
|
|
code, stdout, stderr = run(command + ['--list', '--format', 'terse'])
|
|
create(folder / 'list.stdout', stdout); create(folder / 'list.stderr', stderr)
|
|
require(code == 0 and stderr == b'', 'native list succeeded')
|
|
lines = stdout.decode().splitlines()
|
|
require(len(lines) == 10 and all(line.endswith(': test') for line in lines) and sorted(line[:-6] for line in lines if line.endswith(': test')) == p['all_tests'], 'exact ten names before selecting only two census tests')
|
|
create(folder / 'entered.json', enc({'id': ident, 'run_once': True, 'time_ns': time.time_ns()}))
|
|
code, stdout, stderr = run(command + [p['test_filter'], '--test-threads=1', '--nocapture'])
|
|
create(folder / 'run.stdout', stdout); create(folder / 'run.stderr', stderr)
|
|
after = witness(); create(folder / 'after.json', enc(after))
|
|
require(before == after and code == 0 and stderr == b''
|
|
and b'2 passed; 0 failed; 0 ignored; 0 measured; 8 filtered out' in stdout
|
|
and all((b'test ' + name.encode() + b' ... ok') in stdout for name in p['tests']), 'two selected native census guards, eight filtered and retained target state')
|
|
receipt = dict(id=ident, profile=p['profile'], passed=2, ignored=0, filtered=8, listed=10, execution_uid=0, tests=p['tests'],
|
|
all_tests=p['all_tests'], test_filter=p['test_filter'],
|
|
before=before, after=after, binary_sha256=p['binary_sha256'], source_receipt_sha256=p['receipt_sha256'],
|
|
source_manifest_sha256=p['manifest_sha256'], stdout_sha256=hashlib.sha256(stdout).hexdigest(),
|
|
no_rmm_jobs=True, no_apply=True, no_service_control=True)
|
|
create(folder / 'result.json', enc(receipt)); return receipt
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument('action', choices=('prepare', 'execute', 'read')); parser.add_argument('--case')
|
|
args = parser.parse_args(); os.umask(0o077)
|
|
STATE.mkdir(mode=0o700, parents=True, exist_ok=True); support.private(STATE, True)
|
|
if args.action == 'prepare':
|
|
support.require(args.case is None, 'prepare one new local case')
|
|
receipt_path = QUALIFICATION / 'receipt.json'; support.private(receipt_path)
|
|
support.require(sha(receipt_path.read_bytes()) == RECEIPT_SHA, 'independently reviewed source receipt')
|
|
receipt = support.load(receipt_path); original = support.load(QUALIFICATION / 'inputs.json')
|
|
support.require(sha((QUALIFICATION / 'inputs.json').read_bytes()) == INPUTS_SHA
|
|
and receipt['inputs_sha256'] == INPUTS_SHA and len(original) == 71
|
|
and receipt['input_count'] == 71 and receipt['tests'] == dict(passed=10,failed=0,ignored=0,filtered=0,complete_names=ALL_TESTS)
|
|
and receipt['checks'] == dict(fmt=0,check=0,clippy=0,build=0,list=0,unit=0)
|
|
and receipt['native_apply_run'] is False and receipt['target_calls'] is False,
|
|
'reviewed ten-worker qualification, only two census tests selected')
|
|
ident = str(uuid.uuid4()); folder = STATE / ident; folder.mkdir(mode=0o700)
|
|
copy_exact(receipt_path, folder / 'receipt.json', RECEIPT_SHA, receipt_path.stat().st_size)
|
|
copy_exact(QUALIFICATION / 'inputs.json', folder / 'inputs.json', INPUTS_SHA, (QUALIFICATION / 'inputs.json').stat().st_size)
|
|
paths = set()
|
|
for item in original:
|
|
path = Path(item['path'])
|
|
support.require(not path.is_absolute() and '..' not in path.parts and str(path) not in paths, 'unique fixed frozen input')
|
|
paths.add(str(path)); copy_exact(QUALIFICATION / 'source' / path, folder / 'source' / path, item['sha256'], item['bytes'])
|
|
binary = QUALIFICATION / 'qualified-worker-tests'
|
|
support.require(receipt['binary'] == dict(filename='qualified-worker-tests', bytes=BINARY_BYTES,
|
|
sha256=BINARY_SHA, mode='0500', nlink=1), 'fixed original linked artifact')
|
|
copy_exact(binary, folder / 'worker-census-tests', BINARY_SHA, BINARY_BYTES)
|
|
transports = {path: sha((ROOT / path).read_bytes()) for path in ('deploy/windows_msi_runtime_acceptance.py', 'deploy/vm_access_check.py')}
|
|
save_local(folder / 'manifest.json', dict(id=ident, profile=PROFILE, runner_sha256=sha(Path(__file__).read_bytes()),
|
|
receipt_sha256=RECEIPT_SHA, binary_sha256=BINARY_SHA, binary_bytes=BINARY_BYTES,
|
|
source_files=original, tests=TESTS, all_tests=ALL_TESTS, test_filter=TEST_FILTER, transport_sources=transports))
|
|
verify_case(folder)
|
|
print(json.dumps({'id': ident, 'prepared_locally': True})); return
|
|
support.require(args.case is not None, 'original --case required')
|
|
ident = str(uuid.UUID(args.case)); support.require(ident == args.case, 'same canonical original case')
|
|
folder = STATE / ident; support.private(folder, True); verify_case(folder)
|
|
payload = dict(id=ident, action=args.action, profile=PROFILE, tests=TESTS, all_tests=ALL_TESTS, test_filter=TEST_FILTER, binary_sha256=BINARY_SHA,
|
|
receipt_sha256=RECEIPT_SHA, manifest_sha256=sha((folder / 'manifest.json').read_bytes()),
|
|
agent_sha256=AGENT_SHA, helper_sha256=HELPER_SHA)
|
|
if args.action == 'execute':
|
|
save_local(folder / 'execute-entered.json', {'once': True, 'no_retry': True})
|
|
payload['binary_b64'] = base64.b64encode((folder / 'worker-census-tests').read_bytes()).decode()
|
|
code = 'import json\n' + inspect.getsource(remote) + '\nprint(json.dumps(remote(' + repr(payload) + ')))\n'
|
|
response = support.transport(support.access_settings(ACCESS_ROOT, 'linux'), 'python3 -', code.encode(), folder)
|
|
save_local(folder / (args.action + '-' + str(uuid.uuid4()) + '.json'), response)
|
|
if args.action == 'read' and response['result'] is not None:
|
|
support.require(response['result']['source_manifest_sha256'] == sha((folder / 'manifest.json').read_bytes())
|
|
and response['result']['source_receipt_sha256'] == RECEIPT_SHA
|
|
and response['result']['binary_sha256'] == BINARY_SHA and response['result']['tests'] == TESTS
|
|
and response['result']['passed'] == 2 and response['result']['ignored'] == 0 and response['result']['filtered'] == 8
|
|
and response['result']['listed'] == 10 and response['result']['all_tests'] == ALL_TESTS
|
|
and response['result']['test_filter'] == TEST_FILTER
|
|
and response['result']['before'] == response['result']['after']
|
|
and response['current_witness'] == response['result']['after'], 'same-case retained native result')
|
|
print(json.dumps({'id': ident, 'action': args.action, 'passed': response.get('passed'),
|
|
'complete': response.get('result') is not None if args.action == 'read' else True, 'read_only': args.action == 'read'}))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|