Add sudo-safe pycache redirect and ps-based process discovery fallback#14
Open
wwulfric wants to merge 1 commit into
Open
Add sudo-safe pycache redirect and ps-based process discovery fallback#14wwulfric wants to merge 1 commit into
wwulfric wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
sudoby redirectingsys.pycache_prefixto a safe temporary prefix./proc(e.g., macOS) by falling back topsoutput parsing.Description
peeka/__init__.pywith_running_under_sudo,_sudo_pycache_prefix, and_configure_sudo_bytecode_policyto setsys.pycache_prefixwhen running undersudo, guardable viaPEEKA_DISABLE_SUDO_PYCACHE_REDIRECTand configurable viaPEEKA_SUDO_PYCACHE_PREFIX.peeka/core/processes.pyto return a ps-based fallback by adding_discover_python_processes_with_ps,_python_process_from_fields, and usingsubprocess/shlexto parseps -axo pid=,comm=,command=when/procis unavailable._read_python_processto centralize construction ofPythonProcessobjects and carrycreated_atthrough the new helper.tests/test_import_policy.pycovering the sudo bytecode cache redirection behavior and extendtests/test_processes.pywith tests for thepsfallback and related filtering.Testing
tests/test_import_policy.pywhich exerciseimportlib.reload(peeka)under mockedgeteuidand environment variables, and they passed.tests/test_processes.pyincludingtest_discover_python_processes_falls_back_to_ps_without_procandtest_discover_python_processes_ps_fallback_excludes_current_process, and they passed.Codex Task