fix(manifest): auto-manifest reads the Conda file it actually detected - #1561
Closed
Martin Torp (mtorp) wants to merge 1 commit into
Closed
Martin Torp (mtorp) wants to merge 1 commit into
Martin Torp (mtorp) wants to merge 1 commit into
Conversation
Detection accepted both environment.yml and environment.yaml but only returned a boolean, so the filename was dropped. The generator then read environment.yml unconditionally and failed on any repo using the .yaml spelling, unless a socket.json infile override was in place. Detection now reports which file it found and the generator reads that one. socket.json still wins when it sets infile. Two more things in the same path: - The generated requirements.txt was written relative to the process cwd instead of the target dir, so `socket manifest auto <dir>` and `socket scan create <org> <dir>` dropped it outside the scanned tree. It now resolves against the target dir, which is what the --out flag already documents. - Conda was the one auto-manifest ecosystem with no fail-closed check. Gradle, Maven and sbt abort the run when their generator fails; Conda just set exit 1 and carried on, so a scan uploaded without the pip block and the CLI still exited non-zero. Conda now aborts like the others.
Contributor
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.
The bug
--auto-manifestdetects a Conda project by looking for eitherenvironment.ymlorenvironment.yaml, butdetectManifestActions()only returnedconda: trueand threw the filename away.generateAutoManifest()then readenvironment.ymlunconditionally.So on a repo whose Conda file is
environment.yaml, every run does this:The scan still uploads, the CLI still exits 1. The customer gets a completed scan and a failed CI job on every run, and the packages in the file's
pip:block never reach the scan because the conversion that produces them is the step that failed.The known workaround is a
socket.jsonwithdefaults.manifest.conda.infilepointing at the real filename, which works because that override is the one path that does not go through the hardcoded default.The fix
Detection now reports which file it found (
GeneratableManifests.condaFile) and the generator reads that one. Asocket.jsoninfilestill wins when it is set.Two more bugs in the same code path
The generated
requirements.txtlanded in the wrong directory. It was written relative toprocess.cwd()rather than the target dir, sosocket manifest auto <dir>andsocket scan create <org> <dir>dropped it outside the tree being scanned and the scan never picked it up. The--outflag already documents itself as relative to cwd, so this just makes the code match. Invisible when you run from the repo root, which is what CI does.Conda was the one auto-manifest ecosystem with no fail-closed check. Gradle, Maven and sbt abort the run when their generator fails (#1392); Conda just set exit 1 and carried on. That is what produces the "completed scan + failed CI job" pair, and the scan that uploads is missing the
pip:packages. Conda now callsabortManifestRunIfFailedlike the others.That last one is a deliberate behavior change and the one thing worth a second opinion. Before: scan uploads, exit 1. After: the run stops before upload. It matches the policy the other ecosystems already follow, on the grounds that a partial SBOM silently under-reports dependencies. Happy to drop it if the team would rather warn and continue.
socket manifest condaon its own also falls back to.yamlnow, so the two commands agree on what counts as a Conda file.Verification
Repro, on a directory containing only an
environment.yamlwith apip:block:Manifest Generation Failed: The file was not found at .../environment.yml, exit 1.requirements.txtinto the target dir, exits 0.Also checked:
.ymlunchanged,socket.jsoninfilestill wins over the detected file, and an unreadable Conda file now aborts the run instead of uploading a partial scan.pnpm run checkandpnpm run check:tscpass.src/commands/manifest503 passed,src/commands/scan274 passed. New unit tests cover both detection and the generator branch.Release
No hand-written version bump. The changelog entries go under
## [Unreleased]for the publish workflow to promote.