Repository navigation
chore: add oxfmt and oxlint, and start programs and change files only through vetted helpers - #129
Merged
Merged
Conversation
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.
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.
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:
printWidth: 160, then one mechanical reformat.package-lock.jsonis left alone. oxfmt sorts package.json keys, so plugin keywords are now alphabetical.correctness(oxlint's default) andsuspiciousas 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-sortandunicorn/no-array-reverse(default off, suspicious): off in client and shared code. Their suggestedtoSorted()crashes in Hermes, Paseo's phone runtime.no-restricted-propertiesbanstoSortedandtoReversedthere instead.progress/client/pills.tsx:57.consistent-function-scopingdoesn't see a JSX use of the enclosing scope.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'sexplorer,xdg-open,open,plutiland its Paseo lookup used to start in the daemon's folder and now start in Node's folder, like itsgitalready did.no-restricted-importsbansnode:child_processand every file-changingfsfunction outside*/server/system.ts, Shell Yeah'sproc.ts, Pulse's reporter (which runs inside Playwright), tests and repo scripts.require,createRequire,process.getBuiltinModuleandprocess.bindingare banned too. Proven by planting a rawexecFile, awriteFile, a namespace import, arequireand agetBuiltinModule: oxlint failed on all five..github/workflows/lint.ymlrunsformat:checkandlinton every PR and on pushes to main.The tooling lives in a private root
package.json.npm prefixinside 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:checkandnpm run lintare clean from the root.check:installpass in all seven plugins.npm run security-reviewran on the six plugins whose server code changed:Not covered
import("node:fs").