feat: snapshot Linux-first RMM MVP and pause handover
Rust development slice / linux (push) Failing after 1m10s

This commit is contained in:
BuTzZ
2026-11-12 22:06:25 +01:00
commit 6c3203d725
194 changed files with 49234 additions and 0 deletions
+54
View File
@@ -0,0 +1,54 @@
# Isolated local browser integration — no VM execution
`run_pending.py` uses existing test bootstrap helpers to enroll a real mTLS device
fixture on the local dev backend, never a forged database agent identity. It sends
a ClientHello advertising `run_script` only to exercise plan validation; it does
not implement an executor, ask for a permit, authorize or report an execution.
The browser sends a durable pending request via the actual UI. The fixture is
revoked afterwards; its pending request and enrollment history are retained.
An artifact-count guard checks that jobs/outbox/grants did not increase.
Requirements: initialized/running dev Docker backend on loopback 18443, built UI
served from `web/dist`, public CA `devstate/pki/ca.pem`, private existing browser
login `devstate/browser-login.json` (owned, mode 0600). Credential values are never
CLI arguments, printed or copied into source. No VM credentials are used.
Project-local tools (commands for reproducing setup; actual execution occurred in
the implementation session):
```sh
cd web
npm ci --ignore-scripts
PLAYWRIGHT_BROWSERS_PATH="$PWD/node_modules/.cache/playwright-browsers" npx playwright install chromium
mkdir -p node_modules/.cache/nss-tools
cd node_modules/.cache/nss-tools
apt-get download libnss3-tools
dpkg-deb -x libnss3-tools*.deb root
```
No package installed globally. The runner uses installed `certutil` if available,
otherwise the locally extracted binary. It imports the **public** CA into isolated
`web/node_modules/.cache/browser-home/.pki/nssdb`, with browser HOME restricted to
that directory. Existing global browser/user trust and hosts files are untouched.
DNS overrides map only fixed test names to 127.0.0.1; TLS/SNI still verifies the
original DNS name. No certificate bypass flag or ignoreHTTPS option exists.
From repository root:
```sh
python3 deploy/browser/run_pending.py
```
Real Playwright tests verify normal trusted HTTPS plus rejection of wrong DNS name
and an untrusted CA. The positive UI case only plans/submits and never clicks
approval. CSRF is tested by deleting the token from an actual logout UI request;
403 and continued session visibility are required, followed by valid logout.
No direct API/DB approval path is used. Reporter suppresses raw errors, action logs,
stdout/stderr; traces/screenshots/video are off. Failure artifacts remain private
and must not be published. Sanitized evidence records booleans/statuses only, no
hostnames/keys/passwords. Bounded retries are not automatic: a failing run fails;
a separate rerun must reauthenticate and creates a new explicit pending plan.
`RMM_E2E_MODE=execute` is an additional separate opt-in for the prepared positive
approval/result test, to use only after a real authorized agent path is ready.
This pending-only run is neither native VM evidence nor positive approval proof.
+44
View File
@@ -0,0 +1,44 @@
#!/usr/bin/env python3
"""Explicit future dev/test UI click for one protected immutable case file."""
import argparse
import os
import shutil
import subprocess
import sys
from run_pending import CA, ROOT, STATE, quiet_run
sys.path.insert(0, str(ROOT / 'deploy'))
from vm_mvp_acceptance import protected_json, require, EXECUTABLE
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--case-file', required=True)
parser.add_argument('--dev-test-ui-approve', action='store_true', required=True)
parser.add_argument('--prepare-only', action='store_true')
args = parser.parse_args()
value = protected_json(args.case_file)
require(value.get('profile') == 'dev/test' and value.get('case') in EXECUTABLE
and value.get('expected_principal') == 'simulated-testprincipal-a', 'fixed_dev_test_case_required')
if args.prepare_only:
require(value.get('phase')=='prepare' and value['request']['parameters']['execution_identity']=='root', 'root_UI_preparation_only')
cache = ROOT / 'web/node_modules/.cache'
home = cache / 'browser-home'
nss = home / '.pki/nssdb'; nss.mkdir(parents=True, exist_ok=True, mode=0o700); home.chmod(0o700)
certutil = shutil.which('certutil') or str(cache / 'nss-tools/root/usr/bin/certutil')
if not (nss / 'cert9.db').exists():
quiet_run([certutil, '-N', '-d', 'sql:' + str(nss), '--empty-password'])
quiet_run([certutil, '-A', '-d', 'sql:' + str(nss), '-n', 'RMM isolated development CA', '-t', 'C,,', '-i', str(CA)])
quiet_run([certutil, '-V', '-d', 'sql:' + str(nss), '-n', 'RMM isolated development CA', '-u', 'L'])
env = {k: v for k, v in os.environ.items() if k not in ('DEBUG', 'PWDEBUG', 'NODE_DEBUG')}
env.update(RMM_E2E_PROFILE='dev/test', RMM_E2E_MODE='mvp-prepare' if args.prepare_only else 'mvp-actions', RMM_E2E_CASE_FILE=args.case_file,TZ='UTC',
RMM_E2E_LOGIN_FILE=str(STATE / 'browser-login.json'), PLAYWRIGHT_BROWSERS_PATH=str(cache / 'playwright-browsers'))
return subprocess.run(['npm', 'run', 'test:browser', '--', 'mvp-actions.spec.ts'], cwd=ROOT / 'web', env=env).returncode
if __name__ == '__main__':
try:
sys.exit(main())
except Exception:
print('MVP_BROWSER_INCOMPLETE: private diagnostics withheld')
sys.exit(2)
+76
View File
@@ -0,0 +1,76 @@
#!/usr/bin/env python3
"""Local authenticated synthetic fixture + isolated browser trust; never approve/run a job.
Private login/operator/enrollment values are consumed by existing helpers/browser code,
never printed, passed in argv or placed in browser artifacts. No VM access.
"""
import json
import os
from pathlib import Path
import shutil
import ssl
import subprocess
import sys
import tempfile
ROOT = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(ROOT / 'tests'))
from backend_contract import request # noqa: E402
from local_integration import STATE, CA, A, sql, token, WebSocket, envelope, field # noqa: E402
def quiet_run(args, **kwargs):
result = subprocess.run(args, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, **kwargs)
if result.returncode:
raise RuntimeError('private subprocess failed')
def main():
cache = ROOT / 'web/node_modules/.cache'
home = cache / 'browser-home'
nss = home / '.pki/nssdb'
nss.mkdir(parents=True, exist_ok=True, mode=0o700)
home.chmod(0o700)
certutil = shutil.which('certutil') or str(cache / 'nss-tools/root/usr/bin/certutil')
if not (nss / 'cert9.db').exists():
quiet_run([certutil, '-N', '-d', 'sql:' + str(nss), '--empty-password'])
quiet_run([certutil, '-A', '-d', 'sql:' + str(nss), '-n', 'RMM isolated development CA', '-t', 'C,,', '-i', str(CA)])
quiet_run([certutil, '-V', '-d', 'sql:' + str(nss), '-n', 'RMM isolated development CA', '-u', 'L'])
baseline = sql('SELECT (SELECT count(*) FROM jobs)||\':\'||(SELECT count(*) FROM outbox)||\':\'||(SELECT count(*) FROM execution_permits);')
agent = None
stage = 'authenticated fixture enrollment'
try:
with tempfile.TemporaryDirectory(prefix='browser-fixture-', dir=STATE) as folder:
folder = Path(folder)
quiet_run(['openssl', 'req', '-new', '-newkey', 'ec', '-pkeyopt', 'ec_paramgen_curve:prime256v1', '-nodes', '-keyout', str(folder/'device.key'), '-out', str(folder/'device.csr'), '-subj', '/CN=synthetic-local-browser-contract'])
status, _, enrolled = request('/agent/v1/enroll', 'POST', {'token': token(A), 'csr_pem': (folder/'device.csr').read_text()})
if status != 200: raise RuntimeError('fixture enrollment failed')
agent = enrolled['agent_id']
(folder/'device.pem').write_text(enrolled['certificate_pem'])
context = ssl.create_default_context(cafile=str(CA)); context.load_cert_chain(folder/'device.pem', folder/'device.key')
ws = WebSocket(context)
try:
ws.send(envelope(agent, 1, 0, 10, field(1, 'synthetic-local-browser-contract') + field(2, 'run_script')))
if ws.receive()[0] != 2: raise RuntimeError('fixture mTLS hello failed')
stage = 'browser TLS and pending-only UI checks'
env = {k: v for k, v in os.environ.items() if k not in ('DEBUG', 'PWDEBUG', 'NODE_DEBUG')}
env.update(RMM_E2E_PROFILE='dev/test', RMM_E2E_MODE='pending-only', RMM_E2E_LOGIN_FILE=str(STATE/'browser-login.json'), RMM_E2E_ASSET_ID=enrolled['asset_id'], PLAYWRIGHT_BROWSERS_PATH=str(cache/'playwright-browsers'))
result = subprocess.run(['npm', 'run', 'test:browser', '--', 'pending.spec.ts'], cwd=ROOT/'web', env=env)
if result.returncode: raise RuntimeError('browser checks failed')
stage = 'preapproval execution artifact guard'
after = sql('SELECT (SELECT count(*) FROM jobs)||\':\'||(SELECT count(*) FROM outbox)||\':\'||(SELECT count(*) FROM execution_permits);')
if baseline != after: raise RuntimeError('execution artifacts changed; review concurrent activity')
finally:
ws.close()
except Exception:
print('FAIL: ' + stage + '; private details suppressed.', file=sys.stderr)
return 1
finally:
if agent:
sql(f"UPDATE agent_installations SET revoked_at=now() WHERE agent_id='{agent}';")
print('PASS: isolated browser trust, authenticated local fixture, pending-only UI, no new jobs/outbox/grants. No VM or approval/execution evidence.')
return 0
if __name__ == '__main__':
sys.exit(main())
+54
View File
@@ -0,0 +1,54 @@
#!/usr/bin/env python3
"""Explicit UI-only approval of an already pending Hello-World VM operation.
Planned for use after controlled non-root deployment and sync acceptance. This
runner does not provision an agent, create a plan, or bypass a blocked VM gate.
It uses the same isolated NSS store as run_pending.py, never global trust.
"""
import argparse
import os
from pathlib import Path
import shutil
import subprocess
import sys
import uuid
from run_pending import CA, ROOT, STATE, quiet_run
def identifier(value):
return str(uuid.UUID(value))
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--operation-id', type=identifier, required=True)
parser.add_argument('--asset-id', type=identifier, required=True)
parser.add_argument('--dev-test-approve', action='store_true', required=True)
args = parser.parse_args()
cache = ROOT / 'web/node_modules/.cache'
home = cache / 'browser-home'
nss = home / '.pki/nssdb'
nss.mkdir(parents=True, exist_ok=True, mode=0o700)
home.chmod(0o700)
certutil = shutil.which('certutil') or str(cache / 'nss-tools/root/usr/bin/certutil')
if not (nss / 'cert9.db').exists():
quiet_run([certutil, '-N', '-d', 'sql:' + str(nss), '--empty-password'])
quiet_run([certutil, '-A', '-d', 'sql:' + str(nss), '-n', 'RMM isolated development CA',
'-t', 'C,,', '-i', str(CA)])
quiet_run([certutil, '-V', '-d', 'sql:' + str(nss), '-n', 'RMM isolated development CA', '-u', 'L'])
env = {k: v for k, v in os.environ.items() if k not in ('DEBUG', 'PWDEBUG', 'NODE_DEBUG')}
env.update(RMM_E2E_PROFILE='dev/test', RMM_E2E_MODE='vm-hello',
RMM_E2E_LOGIN_FILE=str(STATE / 'browser-login.json'),
RMM_E2E_ASSET_ID=args.asset_id, RMM_E2E_OPERATION_ID=args.operation_id,
PLAYWRIGHT_BROWSERS_PATH=str(cache / 'playwright-browsers'))
return subprocess.run(['npm', 'run', 'test:browser', '--', 'vm-jobs.spec.ts'],
cwd=ROOT / 'web', env=env).returncode
if __name__ == '__main__':
try:
sys.exit(main())
except Exception:
print('FAIL: VM browser runner incomplete; private diagnostics withheld', file=sys.stderr)
sys.exit(1)
+55
View File
@@ -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)