Skip to content

Commit 00756ab

Browse files
committed
fix(offline): sandbox GENRELEASES_DIR and clean up on failure
- Pin GENRELEASES_DIR to temp dir in scaffold_from_core_pack() so a user-exported value cannot redirect output or cause rm -rf outside the sandbox - Clean up partial project directory on --offline scaffold failure (same behavior as the GitHub-download failure path)
1 parent 55c9bef commit 00756ab

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/specify_cli/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,6 +1262,9 @@ def scaffold_from_core_pack(
12621262

12631263
# Run the release script for this single agent + script type
12641264
env = os.environ.copy()
1265+
# Pin GENRELEASES_DIR inside the temp dir so a user-exported
1266+
# value cannot redirect output or cause rm -rf outside the sandbox.
1267+
env["GENRELEASES_DIR"] = str(tmp / ".genreleases")
12651268
if os.name == "nt":
12661269
cmd = [
12671270
shell_cmd, "-File", str(release_script),
@@ -1990,6 +1993,9 @@ def init(
19901993
"Common causes: missing bash/pwsh, script permission errors, or incomplete wheel.\n"
19911994
"Remove --offline to attempt a GitHub download instead."
19921995
)
1996+
# Clean up partial project directory (same as the GitHub-download failure path)
1997+
if not here and project_path.exists():
1998+
shutil.rmtree(project_path)
19931999
raise typer.Exit(1)
19942000

19952001
# For generic agent, rename placeholder directory to user-specified path

0 commit comments

Comments
 (0)