Skip to content

chore: add oxfmt and oxlint, and start programs and change files only through vetted helpers - #129

Merged
stevecastaneda merged 5 commits into
mainfrom
add-oxfmt-oxlint
Nov 7, 2026
Merged

stevecastaneda merged 5 commits into
mainfrom
add-oxfmt-oxlint

Conversation

@stevecastaneda

Copy link
Copy Markdown
Owner

Why

Steve wants checks that run on every PR without anyone remembering them: a formatter, a linter, and a rule that only lets one vetted file per plugin start programs or change files. That rule targets the bug class behind GHSA-7565-qfx4-6rhj and the Playwright Pulse fixes: raw writes through a .. name or a committed link, and programs started by bare name in the repo's folder, which Windows searches first.

What changes

Five commits, each reviewable alone:

  1. oxfmt 0.77.0, pinned exact because it's pre-1.0, at printWidth: 160, then one mechanical reformat. package-lock.json is left alone. oxfmt sorts package.json keys, so plugin keywords are now alphabetical.
  2. oxlint 1.92.0, pinned, with correctness (oxlint's default) and suspicious as errors, plus fixes for the 131 findings. Turned off or adjusted:
    • no-control-regex (default on, correctness): off in five files whose regexes match control characters on purpose, to strip or refuse them.
    • unicorn/no-array-sort and unicorn/no-array-reverse (default off, suspicious): off in client and shared code. Their suggested toSorted() crashes in Hermes, Paseo's phone runtime. no-restricted-properties bans toSorted and toReversed there instead.
    • One disable comment at progress/client/pills.tsx:57. consistent-function-scoping doesn't see a JSX use of the enclosing scope.
  3. Vetted helpers. Each plugin that needs them gets server/system.ts. Programs start in Node's own folder unless the caller names one. File changes take a trusted folder and a relative name, refuse .. and absolute names, and refuse links on the way. Call sites keep their behavior, with one exception. Progress's explorer, xdg-open, open, plutil and its Paseo lookup used to start in the daemon's folder and now start in Node's folder, like its git already did.
  4. The rule. no-restricted-imports bans node:child_process and every file-changing fs function outside */server/system.ts, Shell Yeah's proc.ts, Pulse's reporter (which runs inside Playwright), tests and repo scripts. require, createRequire, process.getBuiltinModule and process.binding are banned too. Proven by planting a raw execFile, a writeFile, a namespace import, a require and a getBuiltinModule: oxlint failed on all five.
  5. CI. .github/workflows/lint.yml runs format:check and lint on every PR and on pushes to main.

The tooling lives in a private root package.json. npm prefix inside a plugin still returns the plugin folder, so plugin installs don't see it. No version bumps, since nothing user-facing changes.

Checks

  • npm run format:check and npm run lint are clean from the root.
  • Typecheck, tests and check:install pass in all seven plugins.
  • npm run security-review ran on the six plugins whose server code changed:
    • Playwright Pulse, Shell Yeah, Time Since and Workspace Links: no release blockers.
    • History and Progress: blockers, all in code already on main and none from this PR. Progress's four are confirmed and get their own PR. History's depends on a Codex log format that doesn't appear in any of the 324 Codex logs on the dev machine, so it's a follow-up.

Not covered

  • oxlint doesn't check dynamic import("node:fs").
  • Code inside generated script text, like Progress's launcher, isn't linted.

Pins oxfmt 0.77.0 in a private root package.json that only holds repo tooling, with printWidth 160. Every other change is the formatter's own output.
Pins oxlint 1.92.0 with the correctness and suspicious categories as errors, and fixes the code each finding pointed at without changing behavior.

Three config choices instead of code changes:
- no-control-regex is off in the five files whose regexes match control characters on purpose, to strip or refuse them.
- no-underscore-dangle allows _pty, node-pty's own field for the terminal device.
- In client and shared code, which Paseo runs on Hermes on phones, no-array-sort and no-array-reverse are off and toSorted/toReversed are banned instead: Hermes has no Array#toSorted.

One disable comment, in progress/client/pills.tsx: consistent-function-scoping doesn't count a component used as a JSX tag as a use of the scope it closes over.
…safe helpers

Each plugin that starts programs or changes files now does it through one module, server/system.ts, so the safe defaults live in one place per package:

- A program starts in the folder Node lives in unless the caller names a folder it has a reason for.
- A file change names a folder the caller trusts and a relative name inside it. The name can't climb out with `..`, and no folder between the two may be a link.

Call sites keep their behavior, with one exception in Progress: opening a file (explorer, xdg-open, open), reading the default browser (plutil) and asking Paseo where the plugin lives used to start in the daemon's own working folder, and now start in Node's folder like git already did. Windows looks in that folder for a program before PATH. system.test.ts covers it.

Pulse's programs.ts becomes its system.ts. Pulse's reporter, pulse-reporter.mjs, runs inside Playwright and can't import the helper, so it keeps its own writes. Shell Yeah's proc.ts stays the one file there that starts programs.
…tted files

no-restricted-imports bans node:child_process, and every fs and fs/promises function that writes, appends, renames, removes, links, changes modes or opens a file, along with the default and namespace imports that would reach them. They're allowed in each plugin's server/system.ts, Shell Yeah's proc.ts, Pulse's pulse-reporter.mjs, tests, and repo tooling. require, createRequire and process.getBuiltinModule are banned too, since each loads a module past the import rule.
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.

1 participant