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

Merged
SW
1d ago
+748-426

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.