Skip to content

Commit b8c6e49

Browse files
committed
fix: address review comments (iteration #1)
1 parent 6c6b0a6 commit b8c6e49

File tree

3 files changed

+178
-128
lines changed

3 files changed

+178
-128
lines changed

sagemaker-core/src/sagemaker/core/common_utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1689,7 +1689,10 @@ def _is_bad_path(path, base):
16891689
"""
16901690
# joinpath will ignore base if path is absolute
16911691
resolved = _get_resolved_path(joinpath(base, path))
1692-
return os.path.commonpath([resolved, base]) != base
1692+
try:
1693+
return os.path.commonpath([resolved, base]) != base
1694+
except ValueError:
1695+
return True # If we can't determine safety, treat as bad path
16931696

16941697

16951698
def _is_bad_link(info, base):

sagemaker-core/src/sagemaker/core/utils/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
"""
2020
from __future__ import absolute_import
2121

22+
# Public API surface: only non-private functions are exported via __all__.
23+
# Private helpers (_get_resolved_path, _is_bad_path, _is_bad_link, _get_safe_members)
24+
# are still importable directly but are not part of the public API.
2225
__all__ = [
2326
"_save_model",
2427
"download_file_from_url",
@@ -36,6 +39,10 @@
3639
"sagemaker_timestamp",
3740
"sagemaker_short_timestamp",
3841
"get_config_value",
42+
]
43+
44+
# Internal helpers that are importable but not part of the public API
45+
_INTERNAL_NAMES = [
3946
"_get_resolved_path",
4047
"_is_bad_path",
4148
"_is_bad_link",
@@ -45,7 +52,7 @@
4552

4653
def __getattr__(name):
4754
"""Lazy import to avoid circular dependencies."""
48-
if name in __all__:
55+
if name in __all__ or name in _INTERNAL_NAMES:
4956
from sagemaker.core import common_utils
5057

5158
return getattr(common_utils, name)

0 commit comments

Comments
 (0)