]> granicus.if.org Git - graphviz/commitdiff
add a test case for #2257
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 16 Aug 2022 01:22:32 +0000 (18:22 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 20 Aug 2022 16:33:13 +0000 (09:33 -0700)
tests/2257.dot [new file with mode: 0644]
tests/test_regression.py

diff --git a/tests/2257.dot b/tests/2257.dot
new file mode 100644 (file)
index 0000000..1de37a5
--- /dev/null
@@ -0,0 +1 @@
+graph { a -- b; }
index ae0c3153036e7815c369b90ee522c9a166f7af23..8941595c8c2e935607d858b1b091a6bb8c40692b 100644 (file)
@@ -1902,6 +1902,33 @@ def test_2225():
 
   p.check_returncode()
 
+@pytest.mark.xfail(strict=True)
+def test_2257():
+  """
+  `$GV_FILE_PATH` being set should prevent Graphviz from running
+
+  `$GV_FILE_PATH` was an environment variable formerly used to implement a file
+  system sandboxing policy when Graphviz was exposed to the internet via a web
+  server. These days, there are safer and more robust techniques to sandbox
+  Graphviz and so `$GV_FILE_PATH` usage has been removed. But if someone
+  attempts to use this legacy mechanism, we do not want Graphviz to
+  “fail-open,” starting anyway and silently ignoring `$GV_FILE_PATH` giving
+  the user the false impression the sandboxing is in force.
+
+  https://gitlab.com/graphviz/graphviz/-/issues/2257
+  """
+
+  # locate our associated test case in this directory
+  input = Path(__file__).parent / "2257.dot"
+  assert input.exists(), "unexpectedly missing test case"
+
+  env = os.environ.copy()
+  env["GV_FILE_PATH"] = "/tmp"
+
+  # Graphviz should refuse to process an input file
+  with pytest.raises(subprocess.CalledProcessError):
+    subprocess.check_call(["dot", "-Tsvg", input, "-o", os.devnull], env=env)
+
 @pytest.mark.xfail(strict=True)
 def test_2258():
   """