This is an automated email from the ASF dual-hosted git repository.

imbajin pushed a commit to branch feat/oink-core-platform
in repository https://gitbox.apache.org/repos/asf/hugegraph-doc.git

commit 4753dedb7cafae0e55cc200446d042b7980db482
Author: dark <[email protected]>
AuthorDate: Fri Sep 4 19:02:06 2026 +0800

    fix(versioning): guard repository outputs
    
    - reject the repository root and its ancestors as outputs
    - reject every output path nested inside the active checkout
    - cover root, parent, and checkout-child deletion attempts
---
 scripts/test_versioning.py | 10 ++++++++++
 scripts/versioning.py      |  7 +++++++
 2 files changed, 17 insertions(+)

diff --git a/scripts/test_versioning.py b/scripts/test_versioning.py
index b1e3e736e..ffe3469d0 100644
--- a/scripts/test_versioning.py
+++ b/scripts/test_versioning.py
@@ -1101,6 +1101,16 @@ class VersionUrlTest(unittest.TestCase):
                 versioning.prepare_output_directory(symlink, "fixture")
         with self.assertRaises(SystemExit):
             versioning.prepare_output_directory(versioning.ROOT, "fixture")
+        with self.assertRaises(SystemExit):
+            versioning.prepare_output_directory(versioning.ROOT.parent, 
"fixture")
+        checkout_child = versioning.ROOT / ".test-output-must-not-be-deleted"
+        checkout_child.mkdir(exist_ok=True)
+        try:
+            with self.assertRaises(SystemExit):
+                versioning.prepare_output_directory(checkout_child, "fixture")
+            self.assertTrue(checkout_child.is_dir())
+        finally:
+            checkout_child.rmdir()
 
 
 if __name__ == "__main__":
diff --git a/scripts/versioning.py b/scripts/versioning.py
index 57c3d99a5..2620c7b6b 100644
--- a/scripts/versioning.py
+++ b/scripts/versioning.py
@@ -239,6 +239,13 @@ def prepare_output_directory(path: pathlib.Path, label: 
str) -> pathlib.Path:
         allowed_roots.add(pathlib.Path(runner_temp).resolve())
     if not any(root != output and root in output.parents for root in 
allowed_roots):
         fail(f"{label} must be below a controlled temporary directory: 
{output}")
+    repository_root = ROOT.resolve()
+    if (
+        output == repository_root
+        or output in repository_root.parents
+        or repository_root in output.parents
+    ):
+        fail(f"{label} must be outside the repository checkout: {output}")
     if output.exists():
         if output.is_symlink() or not output.is_dir():
             fail(f"{label} is not a removable directory: {output}")

Reply via email to