feat: snapshot Linux-first RMM MVP and pause handover
Rust development slice / linux (push) Failing after 1m10s
Rust development slice / linux (push) Failing after 1m10s
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Verify same-origin build parity with normal CA/SAN validation, no credentials."""
|
||||
import hashlib
|
||||
import http.client
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
import socket
|
||||
import ssl
|
||||
import sys
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
|
||||
|
||||
class LoopbackHTTPS(http.client.HTTPSConnection):
|
||||
def connect(self):
|
||||
sock = socket.create_connection(('127.0.0.1', 18443), timeout=10)
|
||||
self.sock = self._context.wrap_socket(sock, server_hostname='rmm-dev.internal')
|
||||
|
||||
|
||||
def get(path):
|
||||
connection = LoopbackHTTPS('rmm-dev.internal', 18443, context=ssl.create_default_context(cafile=str(ROOT / 'devstate/pki/ca.pem')), timeout=10)
|
||||
try:
|
||||
connection.request('GET', path)
|
||||
response = connection.getresponse()
|
||||
data = response.read(2097153)
|
||||
if response.status != 200 or len(data) > 2097152:
|
||||
raise RuntimeError('bounded asset request failed')
|
||||
return data
|
||||
finally:
|
||||
connection.close()
|
||||
|
||||
|
||||
def main():
|
||||
local_index = (ROOT / 'web/dist/index.html').read_bytes()
|
||||
remote_index = get('/')
|
||||
paths = re.findall(r'(?:src|href)="(/assets/[A-Za-z0-9_.-]+)"', local_index.decode('utf-8'))
|
||||
if not paths:
|
||||
raise RuntimeError('no build asset references')
|
||||
rows = []
|
||||
for path in ['/', *paths]:
|
||||
local = local_index if path == '/' else (ROOT / 'web/dist' / path.lstrip('/')).read_bytes()
|
||||
remote = remote_index if path == '/' else get(path)
|
||||
rows.append({'path': path, 'local_sha256': hashlib.sha256(local).hexdigest(), 'served_sha256': hashlib.sha256(remote).hexdigest(), 'equal': local == remote})
|
||||
result = {'verified_tls': True, 'same_origin': True, 'parity': all(row['equal'] for row in rows), 'assets': rows}
|
||||
print(json.dumps(result, indent=2))
|
||||
return 0 if result['parity'] else 1
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
sys.exit(main())
|
||||
except Exception:
|
||||
print('Asset verification failed; no response contents or private configuration printed.', file=sys.stderr)
|
||||
sys.exit(1)
|
||||
Reference in New Issue
Block a user