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

Add utility functions to get name of GNU tar executable in OS-agnostic manner #276

Merged
merged 24 commits into from
Oct 10, 2023

Conversation

poneill
Copy link
Contributor

@poneill poneill commented Sep 27, 2023

At various points in annotation file processing we rely on tar to compress or decompress files. In particular, we use GNU tar and use certain features that are specific to that implementation. On linux, GNU tar is the default. On MacOSX, however, the default implementation is bsdtar, which is not fully compatible with GNU tar. If we end up calling bsdtar when we mean GNU tar, subtle bugs can result.

So, in order to run tar correctly we need to know which OS we're running it on and specify the correct executable name for GNU tar (or raise an error if it isn't installed). This commit defines a utils module that provides a runtime constant GNU_TAR_EXECUTABLE_NAME valid under linux or MacOSX.

Closes #277



# here and throughout, fully qualify executable names to avoid privilege escalation
GNU_TAR_LINUX = "/usr/bin/tar"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we use something like which to locate this? I'm not sure what privilege escalation is possible with that approach, please help me understand

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, good call, updated to use which to locate these.

In re privilege escalation, if command line names aren't fully qualified, a malicious user with access to $PATH could save an executable named tar in a location that had precedence over /usr/bin and get up to shenanigans. Not the biggest risk in this scenario but it's a belt and suspenders kind of thing.

Copy link
Collaborator

@akotlar akotlar left a comment

Choose a reason for hiding this comment

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

A question and request for install script update

@poneill
Copy link
Contributor Author

poneill commented Oct 2, 2023

@akotlar mind taking another look? Main changes:

  • updated install-mac-deps.sh
  • use which to locate tar/gtar

python/python/bystro/utils/tar.py Outdated Show resolved Hide resolved
python/python/bystro/utils/tar.py Outdated Show resolved Hide resolved
@akotlar
Copy link
Collaborator

akotlar commented Oct 10, 2023

@poneill merge at your convenience

@poneill poneill merged commit 91934b8 into bystrogenomics:master Oct 10, 2023
2 checks passed
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.

linux and macosx use two incompatible tar implementations, leading to bugs on macosx
2 participants