Normalize bundled resource permissions and gate Installer payload modes

这个提交包含在:
mac 于 2026-11-06 10:43:03 +08:00 提交
1 父节点 9f5f065977
当前提交 474bff9ea9
2 个文件已更改
+37 -1

没有与搜索条件相匹配的文件

+32
查看文件
@@ -8,7 +8,9 @@ import os
from pathlib import Path
import plistlib
import shutil
import stat
import subprocess
import tempfile
ROOT = Path(__file__).resolve().parent.parent
APP = Path("/Library/Plug-Ins/FxPlug/大鱼调色.app")
@@ -25,6 +27,33 @@ def history(profile, keychain):
"--keychain", keychain, "--output-format", "json"))["history"]
def check_bundle_access(entries):
for path, mode in entries:
if stat.S_ISLNK(mode):
continue
required = 0o555 if stat.S_ISDIR(mode) or mode & stat.S_IXUSR else 0o444
if mode & required != required:
raise ValueError(f"普通用户无法读取或执行安装载荷:{path}({stat.S_IMODE(mode):04o})")
def check_package_bundle_access(package):
prefix = "." + str(APP)
with tempfile.TemporaryDirectory(dir=CACHE) as scratch:
expanded = Path(scratch) / "expanded"
run("pkgutil", "--expand", str(package), str(expanded))
entries = {}
for bom in expanded.glob("*.pkg/Bom"):
for line in run("lsbom", "-p", "fm", str(bom)).splitlines():
path, mode = line.rsplit("\t", 1)
if path == prefix or path.startswith(prefix + "/"):
if not any(part.startswith("._") for part in Path(path).parts):
entries[path] = int(mode, 8)
if prefix not in entries:
raise ValueError(f"安装载荷清单缺少正式 APP:{APP}")
check_bundle_access(entries.items())
return len(entries)
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--pkg-forge-repo", type=Path,
@@ -51,6 +80,7 @@ def main():
(LOCK / "owner.json").write_text(json.dumps(dict(PID=os.getpid(), cwd=str(ROOT),
product="大鱼调色", phase="PKG packaging", started=datetime.datetime.now(datetime.timezone.utc).isoformat())))
try:
check_bundle_access((path, path.lstat().st_mode) for path in [APP, *APP.rglob("*")])
source = APP / "Contents/Resources/FCP Templates"
staged = CACHE / "pkg-inputs/大鱼调色/大鱼调色"
staged.mkdir(parents=True, exist_ok=True)
@@ -93,6 +123,7 @@ def main():
with log_path.open("w") as log:
subprocess.run(command, stdout=log, stderr=subprocess.STDOUT, check=True)
package = args.output_dir / ("大鱼调色-" + version + ".pkg")
verified_payload_entries = check_package_bundle_access(package)
report_path = ROOT / "verification/Package.json"
subprocess.run(["/usr/bin/python3", str(skill / "verify_fxplug_package.py"), "--manifest", str(manifest_path),
"--package", str(package), "--report", str(report_path)], check=True)
@@ -105,6 +136,7 @@ def main():
report.update(notarization=job, appCompiledSource=delivery["sourceCommit"], appBuild=info["CFBundleVersion"],
packageBuilderRemote="https://dayu.media/git/dayu/pkg-forge.git",
packageBuilderCommit=run("git", "rev-parse", "HEAD", cwd=forge), templateSHA256=hashes,
payloadBundleAccess=dict(entries=verified_payload_entries, scope="Read/traverse modes for installer-owned app entries, from the package BOM"),
installedAppHostAcceptance=delivery.get("hostVerification", "verification/HostLUTLoading.json"),
installScope="本轮仅生成并验包,未再次执行系统安装;正式 APP 已有独立宿主验收。")
report_path.write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n")