ansys-pyensight-core 0.9.2__py3-none-any.whl → 0.9.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ansys-pyensight-core might be problematic. Click here for more details.

@@ -5,7 +5,7 @@ except ModuleNotFoundError: # pragma: no cover
5
5
  __version__ = importlib_metadata.version(__name__.replace(".", "-"))
6
6
 
7
7
  VERSION = __version__
8
- DEFAULT_ANSYS_VERSION = "242"
8
+ DEFAULT_ANSYS_VERSION = "251"
9
9
 
10
10
  # Ansys version number that this release is associated with
11
11
  __ansys_version__ = DEFAULT_ANSYS_VERSION
@@ -1,5 +1,6 @@
1
1
  """ This module provides a list of common utilities shared between different PyEnSight modules."""
2
2
 
3
+ import os
3
4
  import random
4
5
  import re
5
6
  import socket
@@ -214,3 +215,19 @@ def pull_image(docker_client: "DockerClient", image_name: str) -> None:
214
215
  docker_client.images.pull(image_name)
215
216
  except Exception:
216
217
  raise RuntimeError(f"Can't pull Docker image: {image_name}")
218
+
219
+
220
+ def _is_within_directory(directory, target):
221
+ """Check if target is inside of the input directory."""
222
+ abs_directory = os.path.abspath(directory)
223
+ abs_target = os.path.abspath(target)
224
+ return os.path.commonprefix([abs_directory, abs_target]) == abs_directory
225
+
226
+
227
+ def safe_extract(tar, path=".", members=None, *, numeric_owner=False):
228
+ """Utility to check tar extraction to avoid bandit check issue."""
229
+ for member in tar.getmembers():
230
+ member_path = os.path.join(path, member.name)
231
+ if not _is_within_directory(path, member_path):
232
+ raise Exception("Attempted Path Traversal in Tar File")
233
+ tar.extractall(path, members, numeric_owner=numeric_owner)
@@ -325,6 +325,7 @@ class DockerLauncher(Launcher):
325
325
  detach=True,
326
326
  auto_remove=True,
327
327
  remove=True,
328
+ user="ensight:ensight",
328
329
  )
329
330
  else:
330
331
  logging.debug(f"Running container {self._image_name} with cmd {enshell_cmd}\n")
@@ -340,6 +341,7 @@ class DockerLauncher(Launcher):
340
341
  detach=True,
341
342
  auto_remove=True,
342
343
  remove=True,
344
+ user="ensight:ensight",
343
345
  )
344
346
  logging.debug(f"_container = {str(self._container)}\n")
345
347
  else:
@@ -357,6 +359,7 @@ class DockerLauncher(Launcher):
357
359
  detach=True,
358
360
  auto_remove=True,
359
361
  remove=True,
362
+ user="ensight:ensight",
360
363
  )
361
364
  else: # pragma: no cover
362
365
  logging.debug(
@@ -373,6 +376,7 @@ class DockerLauncher(Launcher):
373
376
  detach=True,
374
377
  auto_remove=True,
375
378
  remove=True,
379
+ user="ensight:ensight",
376
380
  )
377
381
  # logging.debug(f"_container = {str(self._container)}\n")
378
382
  logging.debug("Container started.\n")