Skip to content

Commit 8d06fa4

Browse files
authored
Improve robustness in load_module by specifying Exception type (#1032)
Updating the release Dockerfile to include a non-privileged `tfq-user` for improved container security. Moving away from root execution mitigates breakout risks and aligns with the principle of least privilege.
1 parent b6672db commit 8d06fa4

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

tensorflow_quantum/core/ops/load_module.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import types
1919
from distutils.sysconfig import get_python_lib
2020

21+
from tensorflow.python.framework import errors
2122
from tensorflow.python.framework import load_library
2223
from tensorflow.python.platform import resource_loader
2324

@@ -47,7 +48,7 @@ def _load(self):
4748
try:
4849
path = resource_loader.get_path_to_datafile(self._name)
4950
self._module = load_library.load_op_library(path)
50-
except:
51+
except (IOError, errors.NotFoundError):
5152
path = os.path.join(get_python_lib(),
5253
"tensorflow_quantum/core/ops", self._name)
5354
self._module = load_library.load_op_library(path)

0 commit comments

Comments
 (0)