feat: 接入 iOSGuard LLVM 混淆工具链与 IPA 加固门禁,按分支策略兼容旧版本打包

- 新增 toolchain_manager:构建前自愈校验 LLVM opt 工具链,按 Xcode 版本与渠道隔离 obj_cache
- readoor31/readoor31OtherPay Archive 透传 IG_DIST_CHANNEL/IG_OBF_MODE/IG_ALL_GUARD_OFF/IG_RELEASE_SEED
- Archive 前核对分发渠道编译条件:上架包缺失 IG_APPSTORE_DISTRIBUTION 即阻断,非上架包带该条件仅告警,未接入 anti_tamper 的分支跳过
- 导出后执行 IPA 加固门禁审计,失败阻断上传;持久化 dSYM、混淆映射、诊断事件码与审计报告
- 混淆是否执行改由分支 AutoPacking/build_policy.json 声明:force_obfuscation=true 强制,否则按任务勾选,兼容旧分支/旧 Tag;恢复打包页混淆勾选框
- 分支未自带混淆脚本时回退服务端脚本并告警;同步更新服务端 L1 混淆脚本
- .gitignore 忽略 iosguard_cache 与 artifacts 运行时目录;README 补充分支打包策略说明
This commit is contained in:
shenlei
2026-11-24 12:03:54 +09:00
parent d13fcfcdea
commit 83a1db21e5
23 changed files with 3340 additions and 359 deletions
+22 -6
View File
@@ -12,6 +12,7 @@ from fastapi.responses import FileResponse
from starlette.background import BackgroundTask
from sqlalchemy.orm import Session
from ..config import ARTIFACTS_DIR
from ..database import get_db
from ..models import Task
from ..schemas import TaskCreate, TaskResponse
@@ -57,8 +58,11 @@ async def create_task(task: TaskCreate, request: Request, user: dict = Depends(g
project_id = config["_project"]
from ..projects import get_definition
if task.obfuscation and not get_definition(project_id, config)["obfuscation"]:
supports_obfuscation = bool(get_definition(project_id, config)["obfuscation"])
if task.obfuscation and not supports_obfuscation:
raise HTTPException(status_code=400, detail="该项目不支持代码混淆")
# 记录用户勾选;分支 build_policy.json 声明强制混淆时,打包阶段会覆盖为启用并写回。
effective_obfuscation = bool(task.obfuscation) and supports_obfuscation
# 分支与 Tag 不允许重名,按名字即可确定要检出的引用类型
from .config import get_ref_type
@@ -73,7 +77,7 @@ async def create_task(task: TaskCreate, request: Request, user: dict = Depends(g
build_type=task.build_type,
scheme_id=task.scheme_id,
scheme_name=scheme.get("displayName") or scheme_name,
obfuscation=task.obfuscation,
obfuscation=effective_obfuscation,
branch=task.branch,
ref_type=ref_type,
status="pending",
@@ -177,6 +181,9 @@ async def cancel_task(task_id: str, request: Request, user: dict = Depends(get_c
build_path = Path(task.build_dir)
if build_path.exists():
shutil.rmtree(build_path, ignore_errors=True)
task_artifacts = ARTIFACTS_DIR / task_id
if task_artifacts.exists():
shutil.rmtree(task_artifacts, ignore_errors=True)
return {"message": "任务已取消"}
@@ -241,11 +248,14 @@ async def delete_task(task_id: str, request: Request, user: dict = Depends(get_c
if log_path.exists():
log_path.unlink()
# 删除构建目录
# 删除构建目录及持久化产物目录
if task.build_dir:
build_path = Path(task.build_dir)
if build_path.exists():
shutil.rmtree(build_path, ignore_errors=True)
task_artifacts = ARTIFACTS_DIR / task_id
if task_artifacts.exists():
shutil.rmtree(task_artifacts, ignore_errors=True)
from ..services.audit_log import record_operation
record_operation(db, user, "task_deleted", request=request, task=task)
@@ -371,16 +381,22 @@ async def download_dsym(task_id: str, request: Request, user: dict = Depends(get
raise HTTPException(status_code=502, detail=f"生成下载链接失败:{exc}") from exc
return {"url": download_url}
# .dSYM 是目录(macOS bundle),需要压缩为 zip 再下载
# .dSYM 是目录(macOS bundle 或包含 App + IGArchiveGuard.framework 的 dSYMs 目录),需要压缩为 zip 再下载
if os.path.isdir(dsym_path):
zip_path = os.path.join(tempfile.gettempdir(), os.path.basename(dsym_path) + ".zip")
fd, zip_path = tempfile.mkstemp(suffix=".zip")
os.close(fd)
with zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED) as zf:
for root, dirs, files in os.walk(dsym_path):
for f in files:
full = os.path.join(root, f)
arcname = os.path.relpath(full, os.path.dirname(dsym_path))
zf.write(full, arcname)
return FileResponse(zip_path, filename=os.path.basename(zip_path), media_type="application/zip")
return FileResponse(
zip_path,
filename=os.path.basename(dsym_path) + ".zip",
media_type="application/zip",
background=BackgroundTask(os.remove, zip_path),
)
return FileResponse(dsym_path, filename=os.path.basename(dsym_path))