Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(utils): implement symlink sandbox #1146

Conversation

ben-alkov
Copy link
Member

Maintainers will complete the following section

  • Commit messages are descriptive enough
  • Code coverage from testing does not decrease and new code is covered
  • [n/a] JSON/YAML configuration changes are updated in the relevant schema
  • [n/a] Changes to metadata also update the documentation for the metadata
  • Pull request has a link to an osbs-docs PR for user documentation updates

What/why: implement detection/removal of unsafe symlinks in repos, specifically
covering cachi2 use case: Cachito already does this

How:

  • copypasta _enforce_sandbox() and related unit tests from Cachito
    ("cachito/cachito/workers/tasks/general.py" and
    "cachito/tests/test_workers/test_tasks/test_general.py", respectively)
  • add call to _enforce_sandbox()
  • add CLI boolean arg remove-unsafe-symlinks, which toggles removing all
    symlinks which point to location(s) outside of any cloned repository

@ben-alkov ben-alkov requested a review from MartinBasti December 6, 2024 16:50
@ben-alkov ben-alkov self-assigned this Dec 6, 2024
@ben-alkov ben-alkov force-pushed the feat-utils-symlink-sandbox branch 5 times, most recently from 9ccc8a9 to 25b41cc Compare December 6, 2024 20:50
@@ -69,6 +70,50 @@ def __repr__(self):
return self.uri


def _enforce_sandbox(repo_root: str, *, remove_unsafe_symlinks: bool) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

This shouldn't be a private method if we want to use it in atomic-reactor

What/why: implement detection/removal of unsafe symlinks in repos, specifically
covering cachi2 use case: Cachito already does this

How:

- copypasta `_enforce_sandbox()` and related unit tests from Cachito
  ("cachito/cachito/workers/tasks/general.py" and
   "cachito/tests/test_workers/test_tasks/test_general.py", respectively)
- add call to `_enforce_sandbox()`
- add CLI boolean arg `remove-unsafe-symlinks`, which toggles removing all
  symlinks which point to location(s) outside of any cloned repository

Signed-off-by: Ben Alkov <ben.alkov@redhat.com>

rh-pre-commit.version: 2.3.2
rh-pre-commit.check-secrets: ENABLED

Signed-off-by: Ben Alkov <ben.alkov@redhat.com>
@ben-alkov ben-alkov force-pushed the feat-utils-symlink-sandbox branch from 25b41cc to 312d328 Compare December 10, 2024 22:02
@ben-alkov
Copy link
Member Author

Moved implementation to atomic-reactor - it fits better there.

@ben-alkov ben-alkov closed this Dec 17, 2024
@ben-alkov ben-alkov deleted the feat-utils-symlink-sandbox branch January 13, 2025 15:57
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