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

[report] --skip-files is ignored for dirs/symlinks created by Archive class #3841

Open
pmoravec opened this issue Nov 18, 2024 · 0 comments
Open

Comments

@pmoravec
Copy link
Contributor

#3767 is incomplete in the following use case (artificial but simple to understand):

  • have a plugin collecting /lib/alsa/init/info where /lib is a symlink to /usr/lib
  • call sos report --skip-files=/usr/*

Then, the /lib/alsa/init/info files hould not be collected since whole /usr should be skipped. BUT the directory and symlink to it is created within https://github.com/sosreport/sos/blob/main/sos/archive.py#L254-L256 / https://github.com/sosreport/sos/blob/main/sos/archive.py#L258-L260 .

To prevent this, we must guard those two calls by Plugin._is_skipped_path(absdest) condition.

How to implement it in a gentle way? Options:

  • Archive's methods add_file, check_path and _make_leading_paths to have extra argument list of skip paths, and the class will duplicate ``Plugin._is_skipped_path` method - I dont like passing potentially long lists, neither code duplication
  • Archive's methods to pass just Plugin reference as an optional argument, and if present, Plugin._is_skipped_path(absdest) is called as the guard. But I don't like having references to plugins in Archive.
  • the return value from Archive (https://github.com/sosreport/sos/blob/main/sos/report/plugins/__init__.py#L1532) is evaluated against _is_skipped_path, and if True, then..? remove the file/directory/..?

Some other / better idea, how to prevent creating symlinks to forbidden path this way?

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

No branches or pull requests

1 participant