Verify the declared Node entry before completing Agent tasks
Verify control plane / verify (push) Canceled after 0s
Verify control plane / verify (pull_request) Canceled after 0s

This commit is contained in:
WebUp Cloud committed 2026-11-08 23:20:47 +08:00
1 parent da93d4fa1c
commit 6d55806b4f
6 files changed
+113 -9

No files matched your search

+42 -3
View File
@@ -71,6 +71,45 @@ def review_export(root, release=False):
'complete': True, 'totalBytes': total}
def node_start_entry(scripts):
start = scripts.get('start')
build = scripts.get('build')
if not isinstance(start, str) or (isinstance(build, str) and build.strip()):
return None
simple = re.fullmatch(r'node\s+(?:\./)?([\w./-]+\.(?:mjs|cjs|js))', start.strip())
if not simple:
return None
entry = pathlib.PurePosixPath(simple.group(1))
if entry.is_absolute() or '..' in entry.parts or simple.group(1).startswith('-'):
return None
return entry.as_posix()
def workspace_missing_start(root):
package_file = root / 'package.json'
try:
if package_file.is_symlink() or not package_file.is_file():
return None
with package_file.open('rb') as stream:
content = stream.read(256_001)
if len(content) > 256_000:
return None
package = json.loads(content)
except (OSError, ValueError):
return None
scripts = package.get('scripts') if isinstance(package, dict) else None
entry = node_start_entry(scripts) if isinstance(scripts, dict) else None
if entry:
target = root / entry
try:
if target.resolve() == target and target.is_file():
return None
except (OSError, RuntimeError):
pass
return entry
return None
def release_snapshot(root):
snapshot = review_export(root, release=True)
data = base64.b64decode(snapshot['archive'])
@@ -90,9 +129,9 @@ def release_snapshot(root):
or package.get('optionalDependencies'))
if start:
runtime = 'NODE'
simple = re.fullmatch(r'node\s+(?:\./)?([\w./-]+\.(?:mjs|cjs|js))', start)
if simple and not build and simple.group(1) not in names:
raise ValueError('Start file missing: ' + simple.group(1))
entry = node_start_entry(scripts)
if entry and entry not in names:
raise ValueError('Start file missing: ' + entry)
elif build:
runtime = 'STATIC_BUILD'
elif 'index.html' in names: