Skip to content

fix(manager): YAML values as written, structural action locations, fail-closed npm specs - #343

Open
sweepies wants to merge 1 commit into
mainfrom
fix/manager-edits
Open

sweepies wants to merge 1 commit into
mainfrom
fix/manager-edits

Conversation

@sweepies

@sweepies sweepies commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Fixes from the manager-crate scan, all in crates/manager.

What changes and why

  1. YAML writes (edit.rs). An unquoted value was replaced with an unquoted new value whenever it parsed as a number, so tag: 1.9 became tag: 1.10, which Helm reads as 1.1. Invariant: a new plain scalar stays plain only when YAML reads it back as the same string. The check uses serde_yaml_ng (YAML 1.2) plus the YAML 1.1 spellings Go and Ruby parsers still type (yes/on, 010, 1_000, 1:20, floats). Anything else is double-quoted. version: 2 → "3" is also quoted, because Helm renders large integer tags as floats (2.0240101e+07).
  2. YAML reads (yaml.rs). Kustomize newTag, helmCharts[].version, Flux ref.tag and Helm values tag went through float → text, so 1.10 became 1.1 and 2.0 became 2. A plain number is now read as its located source text. edit::scalar does the same for every YAML scalar, so the separate Syntax::YamlName is removed (hard cutover). A GitLab component version is the tail of a larger scalar, so it is now Syntax::InnerToken and never quoted on its own; a whole GitLab ref: follows the YAML rule (ref: "1.10").
  3. Actions locations (actions.rs). uses:/image:/container: were found with a line regex that could match a line inside run: |. They now come from yaml_locations, with the span extended to the end of the line to keep the version comment. Flow-style values still error, as before: a pin comment added inside {…} would swallow the closing bracket.
  4. Actions parse once. yaml_locations is parsed once per workflow file (a Workflow struct carries it), not once per setup-tool step.
  5. npm specs (npm.rs). This now fails closed: only a version, range, dist-tag or npm:name@version alias is a registry spec. Every other scheme: (including gitlab:, bitbucket:, gist: and unknown ones such as jsr:), the owner/repo shorthand, paths and .tgz/.tar files are left alone. This is a structural rule rather than a list of forge prefixes, so a new prefix cannot slip through. The corpus caught a real case: next.js's "ci-info": "watson/ci-info#<sha>" was being looked up on public npm. LOCAL_SCHEMES is now private to public.rs.
  6. Dockerfile heredocs (images.rs). This follows BuildKit's rule: the instruction is split into shell words with quotes kept, and a heredoc is a whole word [fd]<<[-]NAME whose name holds no further <; a quoted name is unquoted. <<<word, "<<EOF" and \<<EOF open no heredoc, so later FROM lines are read.
  7. Go pseudo-versions (go.rs). The commit digest now comes from Go's own pseudo-version pattern (module.IsPseudoVersion), so v1.2.4-0.<ts>-<hash>, v1.0.0-rc.1.0.<ts>-<hash> and +incompatible forms get it too. A dated-looking prerelease that is not a pseudo-version does not.
  8. Lockfile registry check (locked.rs). Any https:// resolved URL used to count as registry. Now a package counts only when its resolved URL is on the public npm registry, or under the registry its .npmrc names for it, or when its settings are unreadable (its lookup then fails rather than guessing). npm::public is reused.
  9. Quadratic checks (locked.rs, npm and aube). Duplicate checks use a BTreeSet. The direct-declaration check, which also scanned every dependency per lock entry, now uses an index built once (Direct); Cargo uses it too.

Snapshots and state versions

  • tests/corpus-extraction.tsv: drops the ci-info owner/repo#sha entry (item 5).
  • tests/corpus-proposals.tsv: the same row, and 8 -0. pseudo-versions in prometheus's go.mod go from pin: to digest:, the same as the v0.0.0- form already was (item 7).
  • crates/manager/src/ is hashed into extract, files, config, config-files, catalog and catalog-controls. These are bumped in tests/state-versions.tsv with their new hashes.

Tests

  • edit.rs: yaml_values_are_quoted_unless_they_read_back_as_the_same_string (Helm values, kustomize tag and chart version, a YAML 1.1 bool), and action_edits_skip_matching_lines_inside_run_scripts. gitlab_numeric_refs_keep_their_text now expects ref: "1.10".
  • wave2.rs: numeric_yaml_tags_and_versions_keep_their_text, dockerfile_here_strings_and_quoted_markers_open_no_heredoc, an fd-and-quoted heredoc case, and all pseudo-version forms in go_pseudo_versions_retain_observed_identity.
  • extract.rs: only_registry_specifiers_are_registry_versions (forge prefixes, shorthand, paths, tarballs, unknown schemes, bare npm: alias) and lockfile_packages_resolved_off_their_registry_are_not_listed (tarball, other path on the private host, mirror, duplicates).
  • Run on the VM: cargo test -p patchula-manager (all pass), cargo clippy -p patchula-manager --all-targets -D warnings, and cargo test -p patchula-engine -p patchula-update -p patchula-lookup (all pass, state parity included).

Docs

guide/managers.md (YAML read/quote rule, npm specs, Actions structural location, Go pseudo-versions, Dockerfile heredocs) and guide/security.md (which lockfile packages count as registry packages).

Dropped

Nothing was dropped. Every scanner claim checked out against the code.

Follow-ups

  • Quoted replacements always use double quotes. They do not yet copy the file's prevailing quote style.
  • The runner-label locator in actions.rs (runner_scope/runners) still finds labels by text within the job's runs-on subtree. It could move to yaml_locations too.

View guided diff Turn on auto-fix

…eps structurally, fail closed on non-registry npm specs

- YAML edits keep a value plain only when YAML (1.2, and the 1.1
  spellings Go and Ruby parsers still use) reads it back as the same
  string; `tag: 1.9` now becomes `tag: "1.10"`, not the float 1.1.
- Kustomize newTag, helmCharts version, Flux ref.tag and Helm values
  tag read a plain number as its source text (`1.10`, `2.0`). The
  separate YamlName syntax is gone: every YAML scalar reads numbers as
  written; a GitLab component version, the tail of a larger scalar, is
  an inner token.
- GitHub Actions uses:/image:/container: values are located through
  yaml_locations, parsed once per file, so a matching line inside a
  run: script is never edited; the span still runs to the end of the
  line to keep the version comment.
- npm: only a version, range, dist-tag or npm:name@version alias is a
  registry spec; every other scheme, the owner/repo shorthand, paths
  and tarballs are left alone.
- Dockerfile heredocs open only at a whole unquoted shell word, as
  BuildKit reads them; here-strings and quoted markers open none.
- Go pseudo-versions record their commit in all three forms.
- package-lock.json packages count as registry packages only when
  resolved on the public registry or on the .npmrc registry for them.
- Lockfile duplicate and direct-declaration checks use indexes instead
  of rescanning.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
count-patchula 71fedbc Commit Preview URL

Branch Preview URL
Nov 15 2026, 11:03 PM

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