Skip to content

Commit

Permalink
Mostieri/dvs module (#494)
Browse files Browse the repository at this point in the history
  • Loading branch information
mariostieriansys committed Jan 15, 2025
1 parent dbd2abf commit 0d55eb7
Show file tree
Hide file tree
Showing 8 changed files with 947 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ jobs:
- name: docker
run: docker pull ${{ env.ENSIGHT_IMAGE }}

#- name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
# env:
# ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER) }}

- name: Run pytest
uses: ansys/actions/tests-pytest@v8
env:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ classifiers = [

dependencies = [
"importlib-metadata>=4.0; python_version<='3.8'",
"ansys-api-pyensight==0.4.5",
"ansys-api-pyensight==0.4.6",
"requests>=2.28.2",
"docker>=6.1.0",
"urllib3<3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/pyensight/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__version__ = importlib_metadata.version(__name__.replace(".", "-"))

VERSION = __version__
DEFAULT_ANSYS_VERSION = "242"
DEFAULT_ANSYS_VERSION = "251"

# Ansys version number that this release is associated with
__ansys_version__ = DEFAULT_ANSYS_VERSION
Expand Down
17 changes: 17 additions & 0 deletions src/ansys/pyensight/core/common.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
""" This module provides a list of common utilities shared between different PyEnSight modules."""

import os
import random
import re
import socket
Expand Down Expand Up @@ -214,3 +215,19 @@ def pull_image(docker_client: "DockerClient", image_name: str) -> None:
docker_client.images.pull(image_name)
except Exception:
raise RuntimeError(f"Can't pull Docker image: {image_name}")


def _is_within_directory(directory, target):
"""Check if target is inside of the input directory."""
abs_directory = os.path.abspath(directory)
abs_target = os.path.abspath(target)
return os.path.commonprefix([abs_directory, abs_target]) == abs_directory


def safe_extract(tar, path=".", members=None, *, numeric_owner=False):
"""Utility to check tar extraction to avoid bandit check issue."""
for member in tar.getmembers():
member_path = os.path.join(path, member.name)
if not _is_within_directory(path, member_path):
raise Exception("Attempted Path Traversal in Tar File")
tar.extractall(path, members, numeric_owner=numeric_owner)
4 changes: 4 additions & 0 deletions src/ansys/pyensight/core/dockerlauncher.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ def start(self) -> "Session":
detach=True,
auto_remove=True,
remove=True,
user="ensight:ensight",
)
else:
logging.debug(f"Running container {self._image_name} with cmd {enshell_cmd}\n")
Expand All @@ -340,6 +341,7 @@ def start(self) -> "Session":
detach=True,
auto_remove=True,
remove=True,
user="ensight:ensight",
)
logging.debug(f"_container = {str(self._container)}\n")
else:
Expand All @@ -357,6 +359,7 @@ def start(self) -> "Session":
detach=True,
auto_remove=True,
remove=True,
user="ensight:ensight",
)
else: # pragma: no cover
logging.debug(
Expand All @@ -373,6 +376,7 @@ def start(self) -> "Session":
detach=True,
auto_remove=True,
remove=True,
user="ensight:ensight",
)
# logging.debug(f"_container = {str(self._container)}\n")
logging.debug("Container started.\n")
Expand Down
Loading

0 comments on commit 0d55eb7

Please sign in to comment.