fix(build): IPA 加固门禁审计按分支脚本支持的参数传参,兼容旧分支打包
旧分支自带的 audit_exported_ipa.py 只支持 ipa / --bundle-id, 服务端传入 --archive、--report-out 等参数会被 argparse 拒绝导致打包失败。 现先解析分支脚本声明的参数,仅传入其支持的选项,旧脚本仍执行基础审计。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
e9449155e4
commit
488c6416c2
@@ -865,6 +865,38 @@ async def test_build_project_passes_dist_channel_and_blocks_on_audit_failure(tmp
|
||||
assert "--archive" in audit_cmd and "--bundle-id" in audit_cmd and "--report-out" in audit_cmd
|
||||
|
||||
|
||||
async def test_exported_ipa_audit_compatible_with_legacy_branch_script(tmp_path, log_streamer):
|
||||
"""旧分支自带审计脚本只支持 ipa / --bundle-id 时,只传其支持的参数,仍执行审计。"""
|
||||
from backend.services.build_service import _run_exported_ipa_audit
|
||||
|
||||
build_dir = tmp_path / "snap"
|
||||
audit_script = build_dir / "iOSGuardIntegration" / "toolchain" / "tools" / "xcode_archive" / "audit_exported_ipa.py"
|
||||
audit_script.parent.mkdir(parents=True)
|
||||
audit_script.write_text(
|
||||
'parser.add_argument("ipa", type=Path)\nparser.add_argument("--bundle-id")\n', encoding="utf-8"
|
||||
)
|
||||
export_path = build_dir / "build"
|
||||
maps_dir = build_dir / "obfuscation_maps"
|
||||
maps_dir.mkdir(parents=True)
|
||||
(maps_dir / "symbol_map_readoor31_1.json").write_text("{}", encoding="utf-8")
|
||||
ipa_path = export_path / "readoor.ipa"
|
||||
|
||||
with patch("asyncio.create_subprocess_exec", return_value=_make_mock_process(0)) as mock_exec:
|
||||
await _run_exported_ipa_audit(
|
||||
"t-legacy",
|
||||
audit_script,
|
||||
ipa_path,
|
||||
export_path / "readoor31.xcarchive",
|
||||
export_path,
|
||||
{"SCHEME": "readoor31", "BUNDLE_ID": "com.test.app"},
|
||||
build_dir,
|
||||
{},
|
||||
)
|
||||
|
||||
audit_cmd = list(mock_exec.call_args.args)
|
||||
assert audit_cmd[1:] == [str(audit_script), str(ipa_path), "--bundle-id", "com.test.app"]
|
||||
|
||||
|
||||
def _dist_channel_snapshot(tmp_path):
|
||||
"""构造接入了 anti_tamper 的源码快照(pbxproj 引用 IGAntiTamper.c)。"""
|
||||
build_dir = tmp_path / "snap"
|
||||
|
||||
Reference in New Issue
Block a user