get('/update', 'App\\Controllers\\Admin\\CloudPageController:update')->add(new SuperAdmin());" ), 'The update page is not protected by the SuperAdmin middleware.'); $assert(str_contains($header, "{if \$admin_can_manage|default:false}
  • actor($request);') === 4, 'Every update controller action must resolve the managed actor.'); $assert(str_contains($controller, 'CloudAccess::manage($actor);'), 'Update API actions do not force CloudAccess::manage.'); $assert(str_contains($controller, "private const UPDATE_BASE = '/internal/v1/update';") && str_contains($controller, "self::UPDATE_BASE . '/settings'") && str_contains($controller, "self::UPDATE_BASE . '/check'") && str_contains($controller, "self::UPDATE_BASE . '/apply'") && str_contains($controller, "self::UPDATE_BASE . '/jobs/' . rawurlencode(\$jobId)"), 'The PHP proxy does not use fixed private engine update paths.'); $assert(str_contains($controller, "CloudInput::only(\$body, ['access_token', 'clear_token']);") && str_contains($controller, "['expected_current_commit', 'expected_remote_commit']"), 'The update proxy request allowlists changed.'); $assert(str_contains($controller, 'new CloudEngineClient(null, 90.0)') && str_contains($controller, '), 202);'), 'Update requests need a Git-aware timeout and apply must return HTTP 202.'); $assert(str_contains($controller, "['access_token', 'gitea_access_token']") && str_contains($controller, "withHeader('Cache-Control', 'no-store')"), 'Update responses are not defensively stripped/no-store.'); $assert(str_contains($controller, "getUri()->getScheme()) === 'https'") && str_contains($controller, "getServerParam('REMOTE_ADDR', '')") && str_contains($controller, "getUri()->getHost()") && str_contains($controller, "['localhost', '127.0.0.1', '::1']") && str_contains($controller, "['127.0.0.1', '::1']") && !str_contains($controller, 'X-Forwarded-Proto'), 'The PHP proxy may accept a repository token over an untrusted transport.'); $assert(str_contains($engineClient, '/internal/v1/update/(?:settings|check|apply|jobs/') && str_contains($engineClient, "\$result['error'] ?? (\$result['detail'] ?? null)") && str_contains($engineClient, 'strlen($detail) > 500'), 'Only bounded safe update errors should pass through the engine client.'); $assert(str_contains($template, 'id="update-repository"') && str_contains($template, 'id="update-branch"') && !str_contains($template, 'https://g.luoli.live/root/virt.git'), 'The fixed repository and branch must be rendered from the API response.'); $assert(preg_match('/]*type="password"[^>]*>/s', $template, $tokenInput) === 1 && !str_contains($tokenInput[0], ' value='), 'The access token field must be an empty password input.'); $assert(str_contains($template, 'id="update-clear-token"') && str_contains($template, '/cloud/update.js?v={$venix_asset_version}') && !str_contains($template, '/cloud/admin.js'), 'The page needs explicit token clearing and its independent update script.'); $assert(str_contains($template, 'engine/requirements.txt') && str_contains($template, 'web/composer.json') && str_contains($template, 'web/composer.lock') && str_contains($template, 'deploy/**') && str_contains($template, '不安装 Composer/Python 依赖') && str_contains($template, '不准备依赖暂存区') && str_contains($template, '不改写 systemd unit') && !str_contains($template, 'PHP 锁定依赖会先隔离准备'), 'The page must describe the code-only update boundary and all rejected paths.'); $assert(str_contains($template, 'blocked') && str_contains($template, '保持维护锁并禁用变更操作') && str_contains($template, '仅回退源码不会解除维护锁') && str_contains($template, '必须人工完成并验证迁移与服务兼容性'), 'Blocked updates must direct the operator to SSH recovery without unlocking mutations.'); foreach (['innerHTML', 'insertAdjacentHTML', 'localStorage', 'sessionStorage', 'document.cookie'] as $unsafeBrowserApi) { $assert(!str_contains($script, $unsafeBrowserApi), 'Update UI must not use unsafe rendering or durable browser storage: ' . $unsafeBrowserApi); } $assert(str_contains($script, '.textContent =') && str_contains($script, "headers['X-Admin-CSRF-Token'] = csrfToken") && str_contains($script, "credentials: 'same-origin'"), 'Safe rendering, CSRF, or same-origin credentials are missing.'); $assert(str_contains($script, "const body = clearToken ? { clear_token: true } : { access_token: token };") && str_contains($script, "tokenInput.value = ''"), 'Blank-token preservation, explicit clearing, or credential cleanup changed.'); $assert(str_contains($script, "window.location.protocol === 'https:'") && str_contains($script, "['localhost', '127.0.0.1', '::1', '[::1]']"), 'The browser may send a repository token over an insecure transport.'); $assert(str_contains($script, 'state.checkedCommits = Object.freeze({') && str_contains($script, 'expected_current_commit: result.current_commit') && str_contains($script, 'expected_remote_commit: result.remote_commit') && str_contains($script, "state.updateAvailable = result.status === 'update_available'") && str_contains($script, 'state.checkedCommits === null || !state.updateAvailable') && str_contains($script, 'state.maintenanceBlocked || !state.updateAvailable'), 'Check results do not pin both commits for apply.'); $assert(str_contains($script, 'settings.token_configured === true && settings.checkout_ready === true') && str_contains($script, 'window.confirm(') && str_contains($script, '仅快进应用代码') && str_contains($script, '不会安装 Composer/Python 依赖或修改 systemd 配置') && str_contains($script, '依赖或部署文件变更必须通过 SSH 升级') && str_contains($script, '执行数据库初始化或迁移'), 'Update readiness or the destructive-impact confirmation changed.'); $assert(substr_count($script, "api('/apply', { method: 'POST', body: pinned })") === 1 && str_contains($script, "api(`/jobs/\${encodeURIComponent(jobId)}`, { method: 'GET' })") && str_contains($script, 'transientFailures > 30') && str_contains($script, 'recoverJobAfterApply') && str_contains($script, '正在只读恢复任务') && str_contains($script, 'job.rollback_ref') && str_contains($script, '人工恢复回滚引用') && str_contains($script, '请勿重复提交'), 'Apply must be single-shot while job polling survives service restarts.'); $assert(str_contains($script, "new Set(['succeeded', 'failed', 'blocked'])") && str_contains($script, 'state.maintenanceBlocked = true') && str_contains($script, "job.status === 'blocked'") && str_contains($script, '代码或数据库状态尚未确认') && str_contains($script, '若任务在数据库迁移期间中断') && str_contains($script, '仅回退源码不会解除维护锁') && str_contains($script, 'busy || state.maintenanceBlocked'), 'Blocked is a polling terminal state but must keep every mutation control locked.'); echo "Admin online-update page, proxy, and browser contracts passed.\n";