启用 `--run-selected` 后,README 中自动选出的命令会在本机执行并继承完整环境
原文依据:5 处复现入口从目标仓库的 README 或其链接文档提取命令并自动选择目标。启用执行后,该命令交给持久运行器;未提供隔离环境时,子进程复制控制器的全部环境变量。恶意或被篡改的仓库文档因此可能把危险命令伪装成示例。
命令可读取或修改用户可访问的文件、使用环境中的凭据并访问网络。超时和取消只能终止进程树,不能撤销已经发生的文件、账户或网络操作。
仅在用户启用 `--run-selected` 时触发,但随后脚本会自动选择从仓库文档提取的命令并在目标仓库目录执行。持久运行器在未传入 `child_env` 时复制当前进程的全部环境,因此不受信任仓库中的恶意文档命令可能读取文件、访问网络或接触环境变量。直接模式减少 shell 解析风险,但不是系统沙箱。用户可要求逐条确认命令,并在隔离环境中以最小环境变量运行。
parser.add_argument("--user-language", default="en", help="Language tag for human-readable reports.") parser.add_argument("--run-selected", action="store_true", help="Execute the selected documented command.") parser.add_argument("--include-analysis-pass", action="store_true", help="Run analyze-project and record its outputs in the stage ledger.")查看另外 4 个位置
) elif args.run_selected: if chosen["selected_goal"] == "training": run_data = maybe_run_training( repo_path=repo_path, command=chosen["documented_command"], train_script=train_execute_script, lane=args.lane, user_language=args.user_language, full_training_authorized=args.full_training_authorized, train_timeout=args.train_timeout, dataset_hint=dataset_hint, checkpoint_hint=checkpoint_hint, resume_from=args.resume_from, max_train_steps=args.max_train_steps, shell_mode=args.shell_mode, runtime_root=runtime_root, model_profile_json=args.model_profile_json, required_model_capabilities=args.require_model_capability, gpu_monitor_enabled=not args.no_gpu_monitor, ) else: run_data = maybe_run_command( repo_path, chosen["documented_command"], args.timeout, args.user_language, args.shell_mode, runtime_root, model_adapter, args.monitor_gpu, ) try: argv = build_command(command, shell_mode) environment = dict(os.environ if child_env is None else child_env) spec["requested_argv"] = list(argv) atomic_write_json(run_dir / "spec.json", spec) if shell_mode == "direct": argv = resolve_direct_argv(argv, repo, environment) spec["argv"] = list(argv) atomic_write_json(run_dir / "spec.json", spec) creationflags = subprocess.CREATE_NEW_PROCESS_GROUP if os.name == "nt" else 0 process = subprocess.Popen( argv, env=environment, cwd=repo, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, encoding="utf-8", errors="replace", bufsize=1, creationflags=creationflags, start_new_session=os.name != "nt", ) except (FileNotFoundError, ShellSyntaxRequired, OSError, ValueError) as exc: chosen = choose_goal(command_data.get("commands", []), repo_path) dataset_hint = derive_dataset_hint(asset_data) else: run_data = maybe_run_command( repo_path, chosen["documented_command"], args.timeout, args.user_language, args.shell_mode, runtime_root, model_adapter, args.monitor_gpu, )