Skip to content

brotli: a never-checked finding no longer reads as already fixed - #11

Merged
devGregA merged 9 commits into
mainfrom
devgrega/brotli-notchecked
Nov 19, 2026
Merged

devGregA merged 9 commits into
mainfrom
devgrega/brotli-notchecked

Conversation

@devGregA

Copy link
Copy Markdown
Contributor

brotli's fix planner (pins.Plan, also used by Sensei's /fix) could report a finding as already fixed when the rescan never checked it again. This makes "already fixed" mean the rescan read the file in full and the pin is gone, or the file was deleted; everything else declines with "rescan to confirm".

Cases that used to read as fixed and now decline

  • A not-checked finding once its file reads again; rules Plan does not handle.
  • Oversized or symlinked text files, unparseable lockfiles and global.json, a line past the end of the file while a vulnerable pin of that rule remains, a line-0 finding while the file still pins a vulnerable release, the same line moving to another vulnerable version, a cancelled scan, a missing root, non-canonical paths.
  • Any release value that is not a literal release after resolution ($var, ${…} forms, $(…), backticks, ${{ … }}, <<…>>): never judged fixed. This one rule covers nvm install $V, URLs with ${V}, ENV X=$OTHER, export X=$(cat …) and the rest.

Behaviour changes callers see

  • Plan keeps its signature.
  • global.json, package.json and packages.lock.json with comments or a byte-order mark are now read and judged.
  • Broken or unexpected-shape lockfiles (including lockfileVersion 1) are reported as not checked instead of being dropped.
  • ENV X=$Y is judged by the ARG value set above it in the same Dockerfile, and the fix edits that line; ${X:-24.22.1} is judged by its default; commented lines are ignored. Edits fed by a variable decline when the ARG crosses build stages.
  • A removed last line, an emptied .nvmrc and a deleted directory read as fixed.

Verification

One independent review pass plus follow-up rounds, each fix with a test that failed first; FuzzPins checks that a finding the scan just reported never plans as already fixed. go test, go vet, -race and the brotli fuzzers pass. main is merged in (Go 1.27.4). Parity runs in CI.

🤖 Generated with Claude Code

devGregA and others added 9 commits November 18, 2026 03:36
pins.Plan took any pin missing on rescan as already fixed unless the file
itself carried a skip, so fix (and Sensei's brotlifix, which copies this
package) reported it fixed when the rescan never checked it. Plan now
returns already only when it read the file in full and the pin is gone
from its line, or the file was deleted; otherwise it declines with
"rescan to confirm":

- a not-checked finding (a skip) or any rule Plan does not plan for (the
  image check's rules), whatever the file holds now;
- a file the rescan cannot read this time: a shell script, Makefile or
  other text candidate that is now oversized or unreadable (its read
  recorded no skip), or any file that is now a symbolic link;
- a skip anywhere in the rescan, not only one on the finding's own file;
- a line past the end of the file;
- a line that now pins another release without the fix (the scan's
  "current" no longer matched, so the pin read as gone);
- a cancelled context (the text patterns stop early without an error);
- a root that is not there, which read every file as deleted.

package-lock.json, npm-shrinkwrap.json, packages.lock.json and global.json
that are not valid JSON were dropped without a skip, by the scan as well
as the plan; they are reported as not checked now.

A deleted Dockerfile or Compose file used to decline (the image reader
records a skip for a missing file); it reads as gone now, like any other
deleted file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A removed last line reads as fixed again. A line past the end of the
  file declines only while the file still pins a release of that rule
  without the fix (or has a skip on any line); read in full with nothing
  left, the pin is gone, wherever its line sat.
- A line 0 finding declines while the file pins any release of that rule
  without the fix.
- Plan cleans the path as Scan does: ./Dockerfile, svc/../Dockerfile and
  svc//compose.yaml no longer read an untouched pin as already fixed.
- A file whose directory was deleted is deleted. Read errors and Plan's
  messages no longer carry the checkout's absolute path.
- Only a skip on the whole file, or on the finding's own line, holds back
  "already fixed"; the message names the line. A digest-only or unresolved
  stage elsewhere in a Dockerfile no longer does.
- The JSON readers see // and /* */ comments and a leading byte-order mark
  as spaces (lines and columns kept): a commented global.json, which the
  .NET SDK accepts, and a package.json or packages.lock.json saved with a
  BOM are read instead of reported as not checked.
- Lockfile skips say what failed: not valid JSON, or JSON of another shape
  (with the parser's message). A lockfileVersion 1 package-lock.json and a
  Pipfile.lock section of another shape are reported as not checked
  instead of dropped.
- FuzzPins checks that a finding the scan just reported never plans as
  already fixed.

Two cases still read as gone, since Plan cannot tell them from a fix (noted
in the code): a pin that moved and changed to another vulnerable release in
a file that did not get shorter, and a path that never held the pin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- An image pin that moved off its line and became a reference the scan
  cannot judge (FROM node:${NODE_VERSION} with no default, a digest-only
  FROM under an added # syntax= line) no longer reads as already fixed:
  for an image finding, or one without props, a skip elsewhere in the
  file holds it back unless a resolved image still sits on the finding's
  own line. A pin fixed in place still reads as fixed, and a text pin is
  held back only by a skip on its own line, as before.
- The text patterns read a JSON file as the JSON readers do, so a value
  inside a comment is not a pin.
- The column of a pin on line 1 does not count a byte-order mark.
- A lockfileVersion 1 package-lock.json with no dependencies is not
  reported as not checked.
- scrub removed "/" too few for a root written with a trailing slash
  ("open .a.json"); it works on the cleaned root.
- Tests for each, and for // and /* */ inside JSON strings and the line
  breaks inside a block comment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A pin that moved off its line and became a value the scan cannot judge
  read as already fixed when any resolved image landed on its old line:
  an ARG with no default, a digest-only FROM pushed down, reordered
  Compose services, Kubernetes containers or GitLab jobs with an unset
  tag, a distroless line image from a variable, and setup-node under an
  unresolved matrix or env value. The scan now records, for every value
  of a rule it judges, its file, line and rule, whatever the verdict; a
  finding whose own line holds no judged value of its rule is held back
  by a skip anywhere in its file. This applies to every finding, not only
  image pins. The cost: a pin replaced by another line, in a file with
  any skip, asks for a rescan.
- The text patterns read a JSON file with its comments blanked only when
  the result is valid JSON. Single-quoted strings (which the comment
  reader does not follow) and an unterminated /* kept real pins out of
  sight; such files are read as written again, and an unterminated /* is
  left alone.
- The byte-order-mark column fix reads line 1 as the column was found,
  so it covers files read only as image files (Dockerfile-prod).
- scrub leaves a relative root alone, and replaces an absolute one only
  where it is a whole path (not inside gcr.io/app/web or /application).
- Tests for each, and for the surviving mutants: a column on line 1
  without a byte-order mark and on a later line with one, a
  lockfileVersion 1 "dependencies" of another shape, scrub with "/" and
  ".".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The judged record is keyed by source as well as rule, and compared with
  the finding's props["source"] (any source without props). A .NET SDK
  image where the aspnet image was, or an ARG NODE_VERSION where the node
  image was, no longer clears a pin that moved and became unresolved.
- Values the scan could not judge (a range, an expression) are no longer
  recorded as judged: textPin, addJudged and the text patterns record
  only through add(). A range landing on the pin's line no longer clears
  it.
- A pin changed in place to an expression is reported as not checked on
  its line instead of dropped: setup-node/bun/dotnet inputs and the env
  and matrix values they read written as ${{ ... }}, Azure versionSpec
  $(var), CircleCI orb << parameters >> and runtime images tagged with a
  << parameter >>, .nvmrc-style and mise/.tool-versions values with ${VAR},
  and ENV/ARG/export NODE_VERSION (BUN, DOTNET, ASPNET) set from a
  variable the file does not itself set to a release.
- The third case Plan cannot tell from a fix (a same-rule, same-source
  value landing on the old line of a pin that became unresolved) is
  documented beside the other two.
- Tests for each, and for the survivors: a line image and a NodeSource
  line fixed in place with a skip elsewhere, a .NET rule through the
  moved logic, a node pin whose line now holds a .NET image, a judged
  value on the next line, and a skip beside a judged value on the line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Follow-up to the approving confirmation review.

- A release slot changed in place to a value the scan does not resolve
  never reads as already fixed: nvm/fnm/volta/asdf/mise with $V, a
  Node.js, NodeSource, Bun or dotnet-install download with ${V} or
  $(cat ...), and a YAML NODE_VERSION/BUN_VERSION: ${{ vars.N }} that no
  setup step reads. The scan records these slots without listing them as
  not checked (the shell sets them in ways it does not follow); Plan
  declines "rescan to confirm" when one sits on a finding's line.
- ENV/ARG/export NODE_VERSION (BUN, DOTNET, ASPNET) set from another
  variable is judged by the value that variable was last set to above it
  in the file, and fixed there (ENV NODE_VERSION=$BUILD_NODE with ARG
  BUILD_NODE=24.22.0 is now a finding; it was missed). Reported once when
  the variable it reads is itself a pin or an image's ARG. A ${X:-d}
  default is judged when X is not set in the file. Only a variable the
  file never sets is listed as not checked.
- Commented-out lines (# or //) are not read by the text patterns.
- A library's TargetFramework on a supported .NET is recorded as judged.
- Tests: fixed values recorded through add (a .tool-versions line beside
  a listed variable), the listing in addJudged (netlify.toml), ranges and
  floating values are not expressions, and the source each reader records
  matches its findings' source.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Final review round: close the class rather than the cases.

- One rule at fix time: when no release of the finding's rule is judged
  on its line and the line holds a value the scan does not resolve (a $
  variable or expansion, $( ), a backtick, ${{ }}, << >>), Plan declines
  "rescan to confirm". It replaces the per-pattern expression slots, and
  covers ${V:?..}, ${V%..}, ${V:+..}, quoted defaults, export X=$(cat ..),
  nvm install v$V, quoted asdf, volta and dotnet-install values, and
  managed runtimes from a variable.
- A text pattern no longer judges the start of a value that goes on as an
  expression (nvm install 24$SUFFIX), and textPin and addJudged never
  judge a value with an unresolved reference in it.
- A version variable is evaluated only when it reads one variable plainly
  or with an unquoted literal default; any other $ or backtick value is
  listed as not checked, as is a variable nothing in scope sets. A shell
  command or URL slot is not listed: the plan declines it in place.
- ARG scope across Dockerfile stages: an ENV reads its own stage's ARG,
  or the global one only through an ARG line in the stage. A variable-fed
  edit is made by hand when the ARG is set in more than one place or a
  FROM reads it.
- A leading # is a comment only where the language says so: in
  JavaScript and TypeScript it is a private field, and CDK runtimes there
  are read.
- One definition of an unresolved value (unresolvedRe), used by the
  listing and the plan.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@devGregA
devGregA merged commit 99aa4ee into main Nov 19, 2026
2 checks passed
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