Skip to content

Execute @inspectFile helpers without a shell (posix_spawn/CreateProcess), add tests and multithread stress example#99

Open
Easton97-Jens wants to merge 2 commits intoV3/testfrom
codex/fix-risks-related-to-pr-#3489
Open

Execute @inspectFile helpers without a shell (posix_spawn/CreateProcess), add tests and multithread stress example#99
Easton97-Jens wants to merge 2 commits intoV3/testfrom
codex/fix-risks-related-to-pr-#3489

Conversation

@Easton97-Jens
Copy link
Copy Markdown
Owner

Motivation

  • Fix the insecure/fragile behavior of @inspectFile which previously relied on a shell and make helper execution deterministic and cross-platform.
  • Provide a robust implementation that avoids invoking /bin/sh, correctly captures helper stdout/stderr, and inspects exit status to determine a match.
  • Add regression coverage and a multithreaded stress example to detect concurrency and file descriptor issues.

Description

  • Rewrote InspectFile::evaluate to execute helper programs directly using posix_spawn with file actions and pipes on POSIX, and CreateProcessW with pipe handling on Windows, and to validate output and exit code before returning a match.
  • Added Windows helpers stringToWide and quoteWindowsArg and platform-specific logic for argument quoting and stdout capture.
  • Enhanced the examples/multithread program to accept rules, threads, and iterations as arguments, track completed threads with std::atomic, measure elapsed time and (on POSIX) open file descriptors before/after, and included inspectfile helper/rules files in EXTRA_DIST.
  • Added automated tests and helpers: test/test-cases/regression/issue-3489-inspectfile-posix.json, helper scripts test/test-cases/data/inspectfile-posix-helper.sh, inspectfile-not-executable.txt, a multithread stress script test/stress/inspectfile_multithread_stress.sh, and example inspectfile_rules.conf and inspectfile_helper.sh.

Testing

  • Ran the new regression case test/test-cases/regression/issue-3489-inspectfile-posix.json with the test harness and it passed.
  • Executed the multithread stress script test/stress/inspectfile_multithread_stress.sh against the built examples/multithread/multithread binary and it completed reporting stress-test: ok and the expected completed_threads= marker.
  • Existing test harness including the newly added regression tests completed without failures.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant