feat(runtime): default to passthrough and persist execution permissions
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { unrestricted, ceiling } from '../../shared/contracts/execution-policy.mjs';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import http from 'node:http';
|
||||
@@ -62,7 +63,7 @@ export class LocalFilePreviews {
|
||||
if (!mediaType) throw fail('此文件类型不用于网页预览。', 403);
|
||||
await verifyWorkspaceProject(this.store, project);
|
||||
const file = safePath(project, resource), stat = fs.statSync(file);
|
||||
if (!stat.isFile() || stat.size > 20 * 1024 * 1024) throw fail('资源不存在或超过 20 MB 预览上限。', 413);
|
||||
if (!stat.isFile() || stat.size > ceiling(this.store, 20 * 1024 * 1024)) throw fail('资源不存在或超过 20 MB 预览上限。', 413);
|
||||
const bytes = fs.readFileSync(file);
|
||||
entry.lastRead = Date.now();
|
||||
response.writeHead(200, { 'Content-Type': mediaType, 'Content-Length': bytes.length });
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { unrestricted } from '../../shared/contracts/execution-policy.mjs';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { randomUUID } from 'node:crypto';
|
||||
@@ -58,7 +59,7 @@ export class PreviewManager {
|
||||
const plan = { schemaVersion: 1, id: randomUUID(), sessionId: session.id, projectId: project.id, taskId: session.taskId, runId: session.runId,
|
||||
root: project.root, workspace: projectWorkspaceIdentity(project), nodeIdentity: node.identity, sourceFingerprint: inspection.sourceFingerprint,
|
||||
cli, script: manifest.scripts.dev, invocation: { executable: node.runtime.node.path, args: [cli.path, '--host', '127.0.0.1', '--port', String(port), '--strictPort', '--clearScreen', 'false'] },
|
||||
port, url: 'http://127.0.0.1:' + port + '/', timeoutMs: 8 * 60 * 60 * 1000, status: 'planned', createdAt: at() };
|
||||
port, url: 'http://127.0.0.1:' + port + '/', timeoutMs: unrestricted(this.store) ? 0 : 8 * 60 * 60 * 1000, status: 'planned', createdAt: at() };
|
||||
plan.fingerprint = hash(seal(plan)); const artifact = this.artifact(session, plan.runId, seal(plan), 'preview-plan');
|
||||
plan.artifactId = artifact.id; plan.artifactSha256 = artifact.sha256;
|
||||
return this.store.putRecord('preview_plan', session, plan, 'preview.planned');
|
||||
|
||||
Reference in New Issue
Block a user