Skip to content

Conversation

@aviruthen
Copy link
Collaborator

Issue #, if available:

Description of changes:
Adds additional input validation and resource management improvements to prevent accidental customer misuse.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

abs_dependency = abspath(dependency)

# Blocklist of sensitive directories that should not be accessible
sensitive_paths = [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this sensitive_paths duplicate of _validate_source_directory's sensitive path? if so, can we refactor to use a common source of sensitive_paths

I can also see another list RESTRICTED_PATH defined in sagemaker-core/src/sagemaker/core/local/data.py, that seem duplicate.
If these are duplicate , can we fix redundancy and use a common list of sensitive/restricted paths ?


# Check for symlinks to prevent symlink-based escapes
if os.path.islink(abs_source):
raise ValueError(f"source_directory cannot be a symlink: {source_directory}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious: Are symlinks not supported for source path ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They should be supported... and this is a good point! Now that I think about it, we don't have to completely prevent sym-links, we just need to resolve the sym-link with os.path.realpath() before validation. This prevents the bug with race conditions. I will make that change

"""A helper class for parsing the byte Event Stream input to provide Line iteration."""

# Maximum buffer size to prevent unbounded memory consumption (10 MB)
MAX_BUFFER_SIZE = 10 * 1024 * 1024
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this to some constants file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Adding it to common_utils.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants