fix(manager): YAML values as written, structural action locations, fail-closed npm specs
Merged
SW
1d ago+748+748+012345678901234567890123456789-426-426-012345678901234567890123456789
Fixes from the manager-crate scan, all in crates/manager.
What changes and why
- YAML writes (
edit.rs). An unquoted value was replaced with an unquoted new value whenever it parsed as a number, sotag: 1.9becametag: 1.10, which Helm reads as1.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). - YAML reads (
yaml.rs). KustomizenewTag,helmCharts[].version, Fluxref.tagand Helm valuestagwent through float → text, so1.10became1.1and2.0became2. A plain number is now read as its located source text.edit::scalardoes the same for every YAML scalar, so the separateSyntax::YamlNameis removed (hard cutover). A GitLab component version is the tail of a larger scalar, so it is nowSyntax::InnerTokenand never quoted on its own; a whole GitLabref:follows the YAML rule (ref: "1.10"). - Actions locations (
actions.rs).uses:/image:/container:were found with a line regex that could match a line insiderun: |. They now come fromyaml_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. - Actions parse once.
yaml_locationsis parsed once per workflow file (aWorkflowstruct carries it), not once per setup-tool step. - npm specs (
npm.rs). This now fails closed: only a version, range, dist-tag ornpm:name@versionalias is a registry spec. Every otherscheme:(includinggitlab:,bitbucket:,gist:and unknown ones such asjsr:), theowner/reposhorthand, paths and.tgz/.tarfiles 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_SCHEMESis now private topublic.rs. - 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]<<[-]NAMEwhose name holds no further<; a quoted name is unquoted.<<<word,"<<EOF"and\<<EOFopen no heredoc, so laterFROMlines are read. - Go pseudo-versions (
go.rs). The commit digest now comes from Go's own pseudo-version pattern (module.IsPseudoVersion), sov1.2.4-0.<ts>-<hash>,v1.0.0-rc.1.0.<ts>-<hash>and+incompatibleforms get it too. A dated-looking prerelease that is not a pseudo-version does not. - Lockfile registry check (
locked.rs). Anyhttps://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.npmrcnames for it, or when its settings are unreadable (its lookup then fails rather than guessing).npm::publicis reused. - Quadratic checks (
locked.rs, npm and aube). Duplicate checks use aBTreeSet. 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 theci-infoowner/repo#shaentry (item 5).tests/corpus-proposals.tsv: the same row, and 8-0.pseudo-versions in prometheus'sgo.modgo frompin:todigest:, the same as thev0.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 intests/state-versions.tsvwith 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), andaction_edits_skip_matching_lines_inside_run_scripts.gitlab_numeric_refs_keep_their_textnow expectsref: "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 ingo_pseudo_versions_retain_observed_identity.extract.rs:only_registry_specifiers_are_registry_versions(forge prefixes, shorthand, paths, tarballs, unknown schemes, barenpm:alias) andlockfile_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, andcargo 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'sruns-onsubtree. It could move toyaml_locationstoo.