You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
113 lines
5.6 KiB
PHP
113 lines
5.6 KiB
PHP
<?php
|
|
|
|
$root = dirname(__DIR__);
|
|
$assert = static function ($condition, string $message): void {
|
|
if (!$condition) {
|
|
throw new RuntimeException($message);
|
|
}
|
|
};
|
|
|
|
$routes = file_get_contents($root . '/config/routes_cloud.php');
|
|
$pages = file_get_contents($root . '/config/routes.php');
|
|
$controller = file_get_contents(
|
|
$root . '/app/Controllers/CloudApiController.php'
|
|
);
|
|
$feature = file_get_contents(
|
|
$root . '/app/Services/Cloud/CloudUserIsoFeature.php'
|
|
);
|
|
$service = file_get_contents(
|
|
$root . '/app/Services/Cloud/CloudUserIsoService.php'
|
|
);
|
|
$orders = file_get_contents(
|
|
$root . '/app/Services/Cloud/CloudOrderService.php'
|
|
);
|
|
$schema = file_get_contents($root . '/sql/cloud.sql');
|
|
$view = file_get_contents($root . '/app/Services/View.php');
|
|
$sidebar = file_get_contents(
|
|
$root . '/resources/views/venix/user/panel_sidebar.tpl'
|
|
);
|
|
$hostAdmin = file_get_contents(
|
|
$root . '/resources/views/venix/admin/hosts/index.tpl'
|
|
);
|
|
$siteAdmin = file_get_contents(
|
|
$root . '/resources/views/venix/admin/config.tpl'
|
|
);
|
|
$siteConfig = file_get_contents(
|
|
$root . '/app/Controllers/Admin/ConfigController.php'
|
|
);
|
|
$adminClient = file_get_contents($root . '/public/cloud/admin-hosts.js');
|
|
|
|
$assert(str_contains($pages, "'/cloud/iso-images'")
|
|
&& str_contains($routes, "['GET', 'POST'], '/user-isos'")
|
|
&& str_contains($routes, "'/user-isos/{id:[0-9a-f]{32}}'")
|
|
&& str_contains($routes, "'/tasks/{id:[0-9]}'") === false
|
|
&& str_contains($routes, "'/tasks/{id:[0-9]+}'")
|
|
&& !str_contains($routes, "'/user-isos/targets'")
|
|
&& str_contains($sidebar, '{if !empty($user_iso_enabled)}')
|
|
&& str_contains($sidebar, 'href="/user/cloud/iso-images"'),
|
|
'The gated personal ISO page and bounded API routes are incomplete.');
|
|
|
|
$assert(substr_count($controller, 'CloudUserIsoFeature::assertEnabled();') === 2
|
|
&& str_contains($feature,
|
|
"public const CONFIG_KEY = 'cloud_user_iso_enabled'")
|
|
&& str_contains($feature, 'return self::$cached = false;')
|
|
&& str_contains($view, "assign('user_iso_enabled'")
|
|
&& !str_contains($hostAdmin, 'id="user-iso-enabled"')
|
|
&& !str_contains($adminClient, 'loadUserIsoSettings')
|
|
&& str_contains($siteAdmin, 'id="cloud_user_iso_enabled"')
|
|
&& str_contains($siteAdmin, 'name="cloud_user_iso_enabled"')
|
|
&& str_contains($siteConfig, 'CloudUserIsoFeature::CONFIG_KEY')
|
|
&& !str_contains($controller, 'userIsoTargets(')
|
|
&& !str_contains($controller, 'userIsoHost('),
|
|
'User ISO exposure must remain globally gated and fail closed.');
|
|
|
|
$assert(str_contains($controller, 'CloudUserIsoService::import(')
|
|
&& str_contains($controller, 'CloudUserIsoService::listing(')
|
|
&& str_contains($controller, 'CloudUserIsoService::delete(')
|
|
&& str_contains($controller, 'return $this->json($response, $job, 202)')
|
|
&& !str_contains($controller, '用户 ISO 现为宿主机级资源,但当前页面尚未提供目标宿主机选择')
|
|
&& !str_contains($controller, '当前宿主机 Agent 尚未实现用户 ISO'),
|
|
'User ISO endpoints must execute the PHP catalog/Agent workflow instead of returning 501.');
|
|
|
|
$assert(str_contains($service, 'final class CloudUserIsoService')
|
|
&& str_contains($service, 'CloudAgentSettingsService::enabledHostIds()')
|
|
&& str_contains($service, 'CloudJobService::reserveAggregate(')
|
|
&& str_contains($service, 'CloudJobService::reserveAgentMutation(')
|
|
&& str_contains($service, "'user_iso_import_replica', 'POST'")
|
|
&& str_contains($service, "'user_iso_delete_replica', 'DELETE'")
|
|
&& str_contains($service, 'CloudJobService::acknowledgement($parent)')
|
|
&& str_contains($service, 'public static function finishJobLocked(')
|
|
&& str_contains($service, 'public static function expireAggregateLocked(')
|
|
&& str_contains($service, 'CloudJobService::completeAggregateLocked(')
|
|
&& !str_contains($service, 'CloudAgentClient')
|
|
&& !str_contains($service, "->request(")
|
|
&& str_contains($service, "CloudSecrets::encrypt(\n ['url' => \$url], 'user-iso-source'")
|
|
&& str_contains($service, "(\$result['id'] ?? null) !== (string) \$iso->id")
|
|
&& str_contains($service, "(int) (\$result['owner_id'] ?? 0) !== (int) \$iso->user_id")
|
|
&& str_contains($service, "preg_match('/^[a-f0-9]{64}\$/D', \$digest)")
|
|
&& str_contains($service, 'MAX_ISOS = 5')
|
|
&& str_contains($service, 'MAX_TOTAL_BYTES = 10 * 1024 * 1024 * 1024'),
|
|
'User ISO service lost its one-shot child dispatch, terminal aggregate, result validation or quota boundary.');
|
|
|
|
$runtime = file_get_contents($root . '/public/cloud/runtime.js');
|
|
$assert(str_contains($orders,
|
|
"if (!in_array(\$source, ['cloud', 'deployment_snapshot'], true))")
|
|
&& str_contains($orders, '实例来源无效')
|
|
&& !str_contains($orders, "'iso_id'")
|
|
&& !str_contains($orders, "\$payload['user_iso_id']")
|
|
&& !str_contains($orders, 'iso_path')
|
|
&& str_contains($runtime,
|
|
"source: state.deployCloudSnapshotKey ? 'deployment_snapshot' : 'cloud'")
|
|
&& !str_contains($runtime, 'body.iso_id')
|
|
&& !str_contains($runtime, "byId('vm-iso')")
|
|
&& !str_contains($runtime, 'body.iso_path ='),
|
|
'VM provisioning must remain limited to cloud templates and deployment snapshots while personal ISOs stay a separate owner library.');
|
|
|
|
$assert(str_contains($schema, 'CREATE TABLE cloud_user_isos')
|
|
&& str_contains($schema, 'sealed_source_url LONGTEXT NOT NULL')
|
|
&& str_contains($schema, 'CREATE TABLE cloud_user_iso_replicas')
|
|
&& str_contains($schema, 'PRIMARY KEY (host_id, user_iso_id)'),
|
|
'Fresh schema must persist PHP-owned ISO identity and per-host Agent replicas.');
|
|
|
|
echo "User ISO PHP catalog and Agent replication contract passed.\n";
|