Skip to content

Fix crash in linux.environ plugin when environ file is missing#1504

Merged
Schamper merged 6 commits intofox-it:mainfrom
B0TAxy:fix/environ_file_not_found_error
Feb 11, 2026
Merged

Fix crash in linux.environ plugin when environ file is missing#1504
Schamper merged 6 commits intofox-it:mainfrom
B0TAxy:fix/environ_file_not_found_error

Conversation

@B0TAxy
Copy link
Copy Markdown
Contributor

@B0TAxy B0TAxy commented Jan 18, 2026

This MR fixes a bug in the linux.environ plugin where attempting to parse the environment of a process would crash if the /proc/<pid>/environ file does not exist (e.g., kernel threads or race conditions during process termination).

Changes:

  • dissect/target/plugins/os/unix/linux/proc.py: Added an explicit .exists() check in _parse_environ before attempting to read the file. It now gracefully returns/skips instead of raising an exception.
  • tests/conftest.py: Updated the fs_linux_proc fixture to simulate a scenario where a process in /proc lacks an environ file (conditional mapping).
  • tests/.../test_environ.py:
  • Updated the expected result count from 4 to 3 (since one process is now correctly skipped due to the missing file).
  • Added a linter suppression comment for the fixture usage.

Testing:

  • Updated existing tests to verify that the plugin no longer crashes on missing files and correctly parses the remaining valid processes.

@Schamper Schamper requested a review from Horofic January 19, 2026 08:33
@B0TAxy
Copy link
Copy Markdown
Contributor Author

B0TAxy commented Feb 6, 2026

Hi @Schamper & @Horofic , checking in on this as it's been open for a few weeks. Since this is a minor fix, I was hoping we could get it in soon. Is there anything blocking this (or anything else needed from my side)?

Comment thread tests/plugins/os/unix/linux/test_environ.py Outdated
Comment thread dissect/target/plugins/os/unix/linux/proc.py Outdated
Comment thread dissect/target/plugins/os/unix/linux/proc.py Outdated
Co-authored-by: Erik Schamper <1254028+Schamper@users.noreply.github.com>
@B0TAxy B0TAxy requested a review from Schamper February 10, 2026 17:47
Comment thread tests/plugins/os/unix/linux/test_environ.py Outdated
@B0TAxy B0TAxy requested a review from Schamper February 11, 2026 17:05
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.93%. Comparing base (4ec38bf) to head (53e59ee).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1504      +/-   ##
==========================================
- Coverage   80.94%   80.93%   -0.02%     
==========================================
  Files         397      397              
  Lines       34892    34893       +1     
==========================================
- Hits        28244    28240       -4     
- Misses       6648     6653       +5     
Flag Coverage Δ
unittests 80.93% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Feb 11, 2026

Merging this PR will not alter performance

✅ 11 untouched benchmarks


Comparing B0TAxy:fix/environ_file_not_found_error (53e59ee) with main (4ec38bf)

Open in CodSpeed

@Schamper Schamper merged commit 495f4be into fox-it:main Feb 11, 2026
15 of 22 checks passed
@B0TAxy B0TAxy deleted the fix/environ_file_not_found_error branch February 11, 2026 20:09
Matthijsy pushed a commit to Matthijsy/dissect.target that referenced this pull request Mar 2, 2026
…ox-it#1504)

Co-authored-by: Erik Schamper <1254028+Schamper@users.noreply.github.com>
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