Repository navigation
refactor(task-runner): share the tracker wire format, document unsafe, validate seccomp jumps - #250
Conversation
…afe blocks The macOS dylib, the Windows DLL and the two parents each carried their own copy of the opcodes, the `[op][path]` framing, the buffer sizes, the pipe name and the opcode-to-kind table. They now come from one dependency-free `fspy_wire` crate: opcodes, `begin`/`encode` (no allocation, never panics, for use inside arbitrary processes), `decode`, `kind_name`, `pipe_name`, the datagram/pipe buffer sizes and the reporting-socket env name. It is a workspace member, so plain `cargo test` runs its tests. Every `unsafe` block in the macOS dylib, the Windows DLL and the two parents now states its invariant in a `// SAFETY:` comment, and `clippy::undocumented_unsafe_blocks` is set to warn in those crates. Magic numbers are named: the write-intent access flags come from `windows-sys`, and the pipe wait, pipe sizes, `poll` timeout and handle counts are named constants or derived from the array they describe. Behaviour is unchanged. Opcode 4 (`missing`) now maps to "missing" on the Windows parent too; the DLL never sends it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ers, document unsafe The filter no longer counts jump offsets by hand. Each jump to the notify return is recorded as it is pushed and patched once that return's position is known. `validate_program` checks that the program ends in `ret ALLOW` then `ret USER_NOTIF`, uses only the expected opcodes, and that every jump stays inside the program and lands on the notify return. It runs as a `debug_assert!` in `build_program` and is covered by tests, including corrupted offsets. `AUDIT_ARCH_*` values are built from libc's `EM_*` numbers and the audit flags, and `__X32_SYSCALL_BIT` gets a name; the tests use the same constants. `SECCOMP_IOCTL_NOTIF_RECV`/`SEND` come from libc (>= 0.2.187) instead of a hand-rolled `_IOWR`, with a test pinning them to the kernel macro's values. The syscall table is built from libc's `SYS_*` constants for the build target (aarch64's `renameat`, which glibc's libc lacks, is a local constant), and compile-time assertions pin each of them to the kernel's number. The helper's exit codes and the `FSPY_SOCK` name are named constants, shared between the helper and the library. Every `unsafe` block carries a `// SAFETY:` comment, and `clippy::undocumented_unsafe_blocks` is set to warn for the crate. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The fspy crates are outside the cargo workspace, so the existing clippy step never linted them or the `cfg`-gated macOS/Windows sources. Clippy now runs on `fspy_seccomp` (Linux job), and on the native addon plus `fspy_macos` / `fspy_windows` on the macOS and Windows runners. The path filters, the macOS native paths and the build cache key include the new `fspy_wire` crate. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
ⓘ Qodo did not review this PR because this workspace reached its daily trial limit of 100 reviews. Reviews start again at 00:00 UTC. Choose a plan to continue now. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
|
Thank you for following the naming conventions! 🙏 |
…assertion Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Merging this PR will not alter performance
Performance Changes
Comparing Footnotes
|
What
A code-review pass over the tracker crates under
packages/tooling/task-runner/native/, in three commits.[u8 op][path]framing, the buffer sizes, the pipe name and the opcode→kind table. They now share one dependency-free crate,fspy_wire:begin/encode(no allocation, never panics, for use inside arbitrary processes),decode,kind_nameandpipe_name;DATAGRAM_MAX,PIPE_MESSAGE_MAX) and the reporting-socket env name.It is a workspace member, so plain
cargo testruns its 14 tests. The Linux tracker has no injected library (the kernel delivers notifications), sofspy_seccompdoes not use it.unsafeand constants.unsafeblock infspy_macos,fspy_windows,fspy_seccompand the root addon (src/macos.rs,src/windows.rs,src/seccomp.rs) has a// SAFETY:comment, andclippy::undocumented_unsafe_blocks = "warn"is set in each of thoseCargo.tomls.windows-sys;SECCOMP_IOCTL_NOTIF_RECV/SENDcome from libc (so the minimum libc is now 0.2.187);AUDIT_ARCH_*values are built from libc'sEM_*;libc::SYS_*(aarch64renameatis a local const because glibc's libc lacks it);poll/pipe sizes, handle counts, helper exit codes andFSPY_SOCKare named constants.build_programno longer counts offsets by hand: each jump to the notify return is recorded when pushed and patched once its position is known.validate_program(also adebug_assert!) checks that the program ends inret ALLOW,ret USER_NOTIF, uses only expected opcodes, and that every jump stays in bounds and lands on the notify return. New tests cover valid programs and corrupted offsets.fspy_seccomp(Linux job) and on the native addon plusfspy_macos/fspy_windowson the macOS/Windows runners. The path filters, macOS native paths and the build cache key includefspy_wire.Behaviour is unchanged, with one unreachable difference: the Windows parent now maps opcode 4 to
"missing"like macOS does. The DLL never sends it.Verification
Run locally on macOS (aarch64):
cargo fmt --checkfor the root workspace and forfspy_macos,fspy_windows,fspy_seccomp.cargo clippy --all-targets -- -D warningsfor the root workspace,fspy_macos,fspy_windows,fspy_seccomp, and the root crate, on x86_64/aarch64 Linux gnu, x86_64/aarch64 Linux musl (fspy_seccomp) and x86_64 Windows msvc (root +fspy_windows).cargo testfor the root workspace (fspy_wire14,task-runner-core169, plus the rest),fspy_macosandfspy_windows(the platform-independentpath/petests, 20).cargo deny --workspace check: ok.Cargo.lockfiles only gainfspy-wire.DYLD_INSERT_LIBRARIESsentread,stat,missingandwritedatagrams in the expected[op][path]layout.filter.rstests (builder,validate_program, corrupted offsets) were executed against a scratch harness that compiles the realfilter.rswith a stand-inlibc(hand-typed constant values). That shows the logic works. It does not show the Linux tests pass.Compile-checked only (not run here): all
fspy_seccomptests and the Linux/Windows code paths, viacargo check --tests/ clippy for the targets above.Never run locally: the Windows runtime (DLL injection, named pipe), the Node/vitest suites (no
node_moduleshere), and the new CI steps. CI covers those.task-runner-corehas no fspy code and was left alone (it has its ownunsafe, not touched here).🤖 Generated with Claude Code