Repository navigation
Add toolchain package verification - #2415
Conversation
|
Tip Atmos Pro
No affected stacks workflow was detected for this pull request. |
Dependency Review✅ No vulnerabilities or license issues found.Scanned Files
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✅ Files skipped from review due to trivial changes (3)
📝 WalkthroughWalkthroughAdds end-to-end package verification to the toolchain installer: schema and registry parsing carry verification metadata; verification (checksums + signatures/attestations) runs against downloaded assets (with cache sidecar URL validation); verifier execution/bootstrapping and lockfile persistence are integrated; tests and docs updated. ChangesChecksum and Signature Verification
Installer Pipeline Integration
Documentation and CI
Estimated code review effort: Possibly Related PRs
Suggested Reviewers
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
|
There was a problem hiding this comment.
Actionable comments posted: 9
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
pkg/toolchain/installer/installer.go (1)
307-313:⚠️ Potential issue | 🟠 Major | ⚡ Quick winMove lockfile write after successful install completion.
On Line 307, the lockfile is updated before
extractAndInstallandos.Chmodsucceed. If extraction fails, you persist a lock entry for a tool that never installed. Update the lockfile only after the binary is fully installed.As per coding guidelines: "Follow Go's error handling idioms... Provide clear error messages to users...".Suggested fix.
verificationResult, err := i.verifyDownloadedAsset(tool, version, effectiveAssetURL, assetPath) if err != nil { _ = os.Remove(assetPath) return "", err } - if err := i.updateLockFile(tool, version, effectiveAssetURL, verificationResult); err != nil { - return "", err - } binaryPath, err := i.extractAndInstall(tool, assetPath, version) if err != nil { return "", fmt.Errorf(errUtils.ErrWrapFormat, ErrFileOperation, err) } if err := os.Chmod(binaryPath, defaultMkdirPermissions); err != nil { return "", fmt.Errorf("%w: failed to make binary executable: %w", ErrFileOperation, err) } + if err := i.updateLockFile(tool, version, effectiveAssetURL, verificationResult); err != nil { + return "", err + }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/toolchain/installer/installer.go` around lines 307 - 313, The lockfile is being updated too early via i.updateLockFile before the install actually succeeds; move the call to i.updateLockFile(tool, version, effectiveAssetURL, verificationResult) to after i.extractAndInstall(tool, assetPath, version) returns no error and any subsequent os.Chmod (or finalization steps) complete successfully so you only persist a lock entry for a successfully installed binary; locate and update the sequence around i.extractAndInstall and ensure errors from extractAndInstall (and chmod) are returned/wrapped as before and only then call i.updateLockFile, keeping the same error handling behavior for failures.
🧹 Nitpick comments (1)
website/src/data/roadmap.js (1)
190-190: 💤 Low valueConsider updating the initiative progress percentage.
The dx initiative progress is currently 91%. As per coding guidelines, when adding a shipped milestone, the initiative progress percentage should be updated. Consider whether this new shipped milestone should increase the progress value.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@website/src/data/roadmap.js` at line 190, The dx initiative object currently sets progress: 91 but a new shipped milestone was added; update the progress field in the dx initiative (the "progress" property in the initiative object in website/src/data/roadmap.js) to reflect the new shipped milestone percentage (recalculate based on your project's progress rules and set progress to the correct integer). Ensure the updated value correctly corresponds to the count/weight of shipped milestones used elsewhere in the roadmap data.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/toolchain/installer/lockfile_update.go`:
- Around line 34-38: The code returns raw errors from lockfile I/O and YAML
parsing (e.g., the call to loadInstallerLockFile when checking i.lockFilePath
and the other returns around lines 54, 100-107, 124-131); update those returns
to wrap the original error using a static sentinel from the package
errors/errors.go (e.g., define or use an appropriate sentinel like ErrLockfileIO
or ErrLockfileParse) and wrap with fmt.Errorf("...: %w", err) to add context.
Concretely, locate calls and returns in lockfile_update.go such as
loadInstallerLockFile(...), YAML unmarshal/parsing points, and any ioutil/os
file operation errors and replace raw returns with fmt.Errorf("failed to
<describe action> for installer lockfile: %w", errors.ErrLockfileIO) or similar,
ensuring the original err is wrapped with %w and the sentinel from
errors/errors.go is included for reliable errors.Is checks.
In `@pkg/toolchain/installer/override.go`:
- Around line 85-99: The current guards in Apply/override logic (checking
override.Checksum, override.Cosign, override.SLSAProvenance, override.Minisign,
override.GitHubArtifactAttestations) only look at a subset of fields and
therefore miss valid configs like checksum.algorithm/pattern,
cosign.signature/bundle, or GitHub attestation predicate_type; add comprehensive
presence checks or central helper functions (e.g.,
hasChecksumConfig(override.Checksum), hasCosignConfig(override.Cosign),
hasSLSAProvenanceConfig(...), hasMinisignConfig(...),
hasGitHubArtifactAttestationsConfig(...)) that return true if any meaningful
field is set and replace the inline boolean expressions so tool.* is assigned
whenever any relevant verification metadata is present.
In `@pkg/toolchain/registry/aqua/aqua.go`:
- Around line 297-311: The hasSLSAProvenance and hasDownloadedFile predicates
currently ignore repository override fields, causing repo-only overrides to be
treated as empty; update hasSLSAProvenance (function name hasSLSAProvenance) to
include checks for s.RepoOwner != "" and s.RepoName != "" in the boolean
expression, and update hasDownloadedFile (function name hasDownloadedFile) to
include checks for f.RepoOwner != "" and f.RepoName != "" so that repo-only
overrides are considered set (keep the nil checks and existing field checks
intact).
In `@pkg/toolchain/registry/atmos/atmos.go`:
- Around line 197-213: parseVerificationFields currently swallows errors from
parseYAMLStruct for fields like tool.Checksum, tool.Cosign, tool.SLSAProvenance,
tool.Minisign and tool.GitHubArtifactAttestations; change
parseVerificationFields to return an error and replace the `_ =
parseYAMLStruct(...)` calls with checks that capture and wrap any error (e.g.
fmt.Errorf("parsing checksum: %w", err)) and return it so malformed
verification/config causes a hard failure; then update any callers of
parseVerificationFields (and the analogous parsing block around the other
occurrence you noted) to handle and propagate the returned error up the registry
parsing flow.
In `@pkg/toolchain/verification/checksum_test.go`:
- Around line 199-200: Replace the broad require.Error(t, err) assertion with an
errors.Is check against the specific contract error ErrDownloadFailed: import
the standard errors package if needed and change the assertion to something like
require.True(t, errors.Is(err, ErrDownloadFailed)) (or use require.ErrorIs if
you prefer), referencing the test-local variable err and the package-level
symbol ErrDownloadFailed in checksum_test.go so the test asserts the exact
failure type.
In `@pkg/toolchain/verification/checksum.go`:
- Around line 287-306: The loop in matchChecksumLine currently overwrites
singleMatch for each non-exact candidate, which allows a last-match to be
returned when multiple ambiguous non-exact candidates exist; update the logic in
checksum.go around singleMatch to track count (e.g., singleMatch and
matchCount), and after scanning if matchCount == 1 return singleMatch, if
matchCount > 1 return a new or existing error (wrap ErrChecksumNotFound or
create ErrChecksumAmbiguous) with assetName to indicate ambiguity, and keep the
scanner.Err() check as-is; adjust references to matchChecksumLine, singleMatch,
and ErrChecksumNotFound accordingly.
In `@pkg/toolchain/verification/runner.go`:
- Around line 26-39: The downloader returns raw errors at
http.NewRequestWithContext, client.Do, and io.ReadAll; wrap each returned error
with the package sentinel ErrDownloadFailed (using fmt.Errorf with %w) and
include the URL or other context string, e.g. replace direct returns from
http.NewRequestWithContext, client.Do(req), and io.ReadAll(resp.Body) with
wrapped errors referencing ErrDownloadFailed so they match the existing
status-code wrapping and the project's error-wrapping policy.
In `@pkg/toolchain/verification/signature_test.go`:
- Around line 287-288: Replace the generic assertion require.Error(t, err) in
signature_test.go's required-signature test with a sentinel check using
require.ErrorIs(t, err, ErrRequiredSignature) (or the actual sentinel error
constant defined in this package for the "required signature" case); locate the
assertion call require.Error(t, err) in the test and change it to
require.ErrorIs using the package's sentinel (e.g., ErrRequiredSignature or the
specific error constant) so the test verifies the exact expected error via
errors.Is.
In `@pkg/toolchain/verification/signature.go`:
- Around line 255-264: When constructing sidecar URLs you must apply
replaceVersionSegmentInURL to the rendered string so v-prefixed segments are
normalized; update the branches that return sidecar.URL (the result of
renderTemplateString(sidecar.URL,...)) and the branch that returns sidecarAsset
(when sidecar.Type == "http") to call replaceVersionSegmentInURL(renderedURL,
tool, version) before returning. Locate the calls to renderTemplateString in
this function and wrap their results with replaceVersionSegmentInURL using the
existing tool and version variables so both returned URLs are normalized.
---
Outside diff comments:
In `@pkg/toolchain/installer/installer.go`:
- Around line 307-313: The lockfile is being updated too early via
i.updateLockFile before the install actually succeeds; move the call to
i.updateLockFile(tool, version, effectiveAssetURL, verificationResult) to after
i.extractAndInstall(tool, assetPath, version) returns no error and any
subsequent os.Chmod (or finalization steps) complete successfully so you only
persist a lock entry for a successfully installed binary; locate and update the
sequence around i.extractAndInstall and ensure errors from extractAndInstall
(and chmod) are returned/wrapped as before and only then call i.updateLockFile,
keeping the same error handling behavior for failures.
---
Nitpick comments:
In `@website/src/data/roadmap.js`:
- Line 190: The dx initiative object currently sets progress: 91 but a new
shipped milestone was added; update the progress field in the dx initiative (the
"progress" property in the initiative object in website/src/data/roadmap.js) to
reflect the new shipped milestone percentage (recalculate based on your
project's progress rules and set progress to the correct integer). Ensure the
updated value correctly corresponds to the count/weight of shipped milestones
used elsewhere in the roadmap data.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: c39959d8-2e93-41b0-98d5-c04de29adacc
📒 Files selected for processing (24)
CHANGELOG.mdpkg/schema/schema.gopkg/toolchain/installer/download.gopkg/toolchain/installer/download_test.gopkg/toolchain/installer/installer.gopkg/toolchain/installer/lockfile_update.gopkg/toolchain/installer/override.gopkg/toolchain/installer/verification_integration_test.gopkg/toolchain/lockfile/lockfile.gopkg/toolchain/registry/aqua/aqua.gopkg/toolchain/registry/aqua/aqua_test.gopkg/toolchain/registry/atmos/atmos.gopkg/toolchain/registry/registry.gopkg/toolchain/verification/checksum.gopkg/toolchain/verification/checksum_test.gopkg/toolchain/verification/runner.gopkg/toolchain/verification/signature.gopkg/toolchain/verification/signature_test.gopkg/toolchain/verification/template.gopkg/toolchain/verification/types.gopkg/toolchain/verification/verifier.gowebsite/blog/2026-05-16-toolchain-package-verification.mdxwebsite/docs/cli/configuration/toolchain/index.mdxwebsite/src/data/roadmap.js
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2415 +/- ##
==========================================
+ Coverage 78.16% 78.24% +0.08%
==========================================
Files 1112 1119 +7
Lines 105270 106201 +931
==========================================
+ Hits 82281 83099 +818
- Misses 18425 18463 +38
- Partials 4564 4639 +75
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
…verify # Conflicts: # pkg/toolchain/installer/installer.go
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
pkg/toolchain/installer/verifier_command_test.go (2)
139-181: ⚡ Quick winPrefer generated mocks over hand-written registry stubs.
The manual stub types here work, but they’re more brittle when
registry.ToolRegistryevolves. Switching tomockgenmocks would keep interface drift visible at compile time. As per coding guidelines, "Prefer unit tests with mocks over integration tests; use interfaces and dependency injection for testability; generate mocks withgo.uber.org/mock/mockgen...; never manual mocks."🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/toolchain/installer/verifier_command_test.go` around lines 139 - 181, Replace the hand-written stubs verifierBootstrapFactory and verifierBootstrapRegistry (and their methods NewAquaRegistry, GetTool, GetToolWithVersion, GetLatestVersion, LoadLocalConfig, Search, ListAll, GetMetadata) with a mock generated by go.uber.org/mock/mockgen: add an interface-targeted mock for registry.ToolRegistry, generate the mock package, import the generated mock in verifier_command_test.go, and update the test to instantiate the mock, set expectations/return values for the methods used (GetTool, GetToolWithVersion, GetLatestVersion, etc.) and inject it via verifierBootstrapFactory.NewAquaRegistry; ensure the mock generation is added to the repo's dev tools (or makefile) so interface changes cause compile-time errors.
64-75: ⚡ Quick winAdd an explicit env-propagation prerequisite sub-test first.
These helper-process tests assume env vars reach the subprocess. A small prerequisite sub-test would make failures much easier to diagnose and de-flake cross-platform runs. As per coding guidelines, "Add prerequisite sub-tests for subprocess behavior: when a test depends on implicit env propagation, add an explicit sub-test confirming the behavior before the main test runs."
Also applies to: 77-117
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/toolchain/installer/verifier_command_test.go` around lines 64 - 75, Add a short prerequisite sub-test at the start of TestVerifierCommandRunnerUsesExistingCommandOnPath (and the sibling test block covering lines 77-117) that asserts environment vars are propagated to subprocesses: spawn the same helper process checking ATMOS_VERIFIER_HELPER_PROCESS or a unique test env key and require it is seen by the child before running the main assertions; update the test function(s) around verifierCommandRunner.Run and the use of ATMOS_VERIFIER_HELPER_PROCESS to first run this sub-test and fail early with a clear message if env propagation doesn't work so the main test doesn't flake.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/toolchain/installer/download.go`:
- Around line 274-282: Fallback failure currently always returns
buildDownloadNotFoundError even when the fallback error is a
network/5xx/timeout; modify the logic in the download path after calling
i.downloadAsset(fallbackURL) (the block that currently checks err == nil at the
end of the download flow) to inspect and propagate non-404 HTTP errors: if
i.downloadAsset(fallbackURL) returns a non-nil err, unwrap/inspect it (e.g.
check for ErrHTTPRequest / an HTTP status code on the wrapped error or use
errors.As to find the HTTP error type) and if the status is not 404 (or the
error is a timeout/5xx/network error) return that err directly (return "", "",
err); only fall back to buildDownloadNotFoundError(tool.RepoOwner,
tool.RepoName, version, assetURL, fallbackURL) when both attempts actually
indicate “not found” (404).
- Around line 69-73: cachedAssetMatchesURL currently treats a missing .url
sidecar as a cache hit because it returns os.IsNotExist(err); change the logic
so that any read error (including IsNotExist) yields false, then compare the
file contents to the provided url; specifically update cachedAssetMatchesURL to
return false when os.ReadFile(cacheSourceURLPath(cachePath)) returns an error
and only return true if the read succeeds and the file contents equal the url
string.
---
Nitpick comments:
In `@pkg/toolchain/installer/verifier_command_test.go`:
- Around line 139-181: Replace the hand-written stubs verifierBootstrapFactory
and verifierBootstrapRegistry (and their methods NewAquaRegistry, GetTool,
GetToolWithVersion, GetLatestVersion, LoadLocalConfig, Search, ListAll,
GetMetadata) with a mock generated by go.uber.org/mock/mockgen: add an
interface-targeted mock for registry.ToolRegistry, generate the mock package,
import the generated mock in verifier_command_test.go, and update the test to
instantiate the mock, set expectations/return values for the methods used
(GetTool, GetToolWithVersion, GetLatestVersion, etc.) and inject it via
verifierBootstrapFactory.NewAquaRegistry; ensure the mock generation is added to
the repo's dev tools (or makefile) so interface changes cause compile-time
errors.
- Around line 64-75: Add a short prerequisite sub-test at the start of
TestVerifierCommandRunnerUsesExistingCommandOnPath (and the sibling test block
covering lines 77-117) that asserts environment vars are propagated to
subprocesses: spawn the same helper process checking
ATMOS_VERIFIER_HELPER_PROCESS or a unique test env key and require it is seen by
the child before running the main assertions; update the test function(s) around
verifierCommandRunner.Run and the use of ATMOS_VERIFIER_HELPER_PROCESS to first
run this sub-test and fail early with a clear message if env propagation doesn't
work so the main test doesn't flake.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 8cfc17bc-6169-442b-b666-f6a4bee3706d
📒 Files selected for processing (31)
.claude/skills/docs/SKILL.md.github/workflows/test.ymlCHANGELOG.mdagent-skills/skills/atmos-toolchain/SKILL.mddocs/prd/auth-session-management.mddocs/prd/component-path-resolution.mdpkg/toolchain/installer/download.gopkg/toolchain/installer/download_test.gopkg/toolchain/installer/installer.gopkg/toolchain/installer/installer_test.gopkg/toolchain/installer/lockfile_update.gopkg/toolchain/installer/lockfile_update_test.gopkg/toolchain/installer/override_verification_test.gopkg/toolchain/installer/verifier_command_test.gopkg/toolchain/registry/aqua/aqua.gopkg/toolchain/registry/aqua/aqua_test.gopkg/toolchain/registry/aqua/version.gopkg/toolchain/registry/verification_helpers_test.gopkg/toolchain/verification/assertions_test.gopkg/toolchain/verification/checksum_test.gopkg/toolchain/verification/runner_test.gopkg/toolchain/verification/signature_test.gopkg/toolchain/verification/template_test.gopkg/toolchain/verification/types_test.gowebsite/blog/2026-05-16-toolchain-package-verification.mdxwebsite/docs/ai/agent-skills.mdxwebsite/docs/cli/commands/toolchain/usage.mdxwebsite/docs/cli/configuration/toolchain/index.mdxwebsite/docs/cli/configuration/toolchain/verification.mdxwebsite/docs/functions/yaml/include.raw.mdxwebsite/src/data/roadmap.js
💤 Files with no reviewable changes (1)
- CHANGELOG.md
✅ Files skipped from review due to trivial changes (5)
- docs/prd/auth-session-management.md
- docs/prd/component-path-resolution.md
- agent-skills/skills/atmos-toolchain/SKILL.md
- website/docs/ai/agent-skills.mdx
- website/blog/2026-05-16-toolchain-package-verification.mdx
🚧 Files skipped from review as they are similar to previous changes (14)
- pkg/toolchain/installer/override_verification_test.go
- pkg/toolchain/registry/verification_helpers_test.go
- website/src/data/roadmap.js
- pkg/toolchain/installer/installer_test.go
- pkg/toolchain/verification/types_test.go
- pkg/toolchain/verification/runner_test.go
- pkg/toolchain/installer/download_test.go
- pkg/toolchain/verification/signature_test.go
- pkg/toolchain/installer/installer.go
- pkg/toolchain/verification/template_test.go
- pkg/toolchain/registry/aqua/aqua.go
- pkg/toolchain/installer/lockfile_update.go
- pkg/toolchain/verification/checksum_test.go
- pkg/toolchain/registry/aqua/aqua_test.go
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pkg/toolchain/installer/verification_integration_test.go (1)
136-138: ⚡ Quick winConsider making the error assertion more precise.
The test accepts either
ErrChecksumMismatchorErrChecksumNotFound, but given the test setup (FileFormat: "raw" with a valid checksum value), you should consistently getErrChecksumMismatchwhen the cached file doesn't match. Accepting two error types makes it harder to catch regressions if the verification behavior changes.If both errors are genuinely valid in different scenarios, add a comment explaining when each can occur.
More precise assertion
- assert.True(t, errors.Is(err, verification.ErrChecksumMismatch) || errors.Is(err, verification.ErrChecksumNotFound)) + require.ErrorIs(t, err, verification.ErrChecksumMismatch)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/toolchain/installer/verification_integration_test.go` around lines 136 - 138, The test currently allows either verification.ErrChecksumMismatch or verification.ErrChecksumNotFound making the expectation loose; update the assertion to require verification.ErrChecksumMismatch (since the setup uses FileFormat "raw" with a provided checksum and the cached file content should deterministically cause a mismatch) by replacing the OR assertion with a single check using errors.Is(err, verification.ErrChecksumMismatch) and keep the require.Error(t, err) and assert.NoFileExists(t, cachedPath) lines unchanged; if you intentionally need to accept both cases, instead add a short comment near the assertion explaining the specific scenarios that produce ErrChecksumMismatch vs ErrChecksumNotFound.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@pkg/toolchain/installer/verification_integration_test.go`:
- Around line 136-138: The test currently allows either
verification.ErrChecksumMismatch or verification.ErrChecksumNotFound making the
expectation loose; update the assertion to require
verification.ErrChecksumMismatch (since the setup uses FileFormat "raw" with a
provided checksum and the cached file content should deterministically cause a
mismatch) by replacing the OR assertion with a single check using errors.Is(err,
verification.ErrChecksumMismatch) and keep the require.Error(t, err) and
assert.NoFileExists(t, cachedPath) lines unchanged; if you intentionally need to
accept both cases, instead add a short comment near the assertion explaining the
specific scenarios that produce ErrChecksumMismatch vs ErrChecksumNotFound.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: a93a2cde-5cd8-41b9-947e-eb709345a1c8
📒 Files selected for processing (3)
pkg/toolchain/installer/installer.gopkg/toolchain/installer/lockfile_update.gopkg/toolchain/installer/verification_integration_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
- pkg/toolchain/installer/lockfile_update.go
- pkg/toolchain/installer/installer.go
There was a problem hiding this comment.
🧹 Nitpick comments (2)
pkg/toolchain/installer/verification_integration_test.go (2)
117-117: 💤 Low valueSidecar write duplicates the production on-disk format.
This test (and several in
download_test.go) hand-rolls theurl+"\n"sidecar payload thatwriteCacheSourceURLindownload.goproduces. If the on-disk format ever changes (e.g., adds a header, switches to JSON), every test seeding the sidecar drifts silently. Consider exporting a small test helper that calls the samewriteCacheSourceURL(or a package-privateseedCacheSourceURL(t, cachePath, url)) so tests and production share one source of truth.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/toolchain/installer/verification_integration_test.go` at line 117, The test is hand-writing the cache sidecar format instead of using the production writer; change tests to call the same writer so format stays in sync by adding a small test helper (e.g., a package-private seedCacheSourceURL(t, cachedPath, url) or reuse writeCacheSourceURL) and update tests like verification_integration_test.go to call that helper instead of directly writing url+"\n" to cacheSourceURLPath(cachedPath); ensure the helper uses the existing writeCacheSourceURL implementation so all tests share the single source of truth for the on-disk sidecar format.
102-140: ⚡ Quick winConsider adding a negative-path companion test for cached-asset deletion.
TestInstallFromTool_RemovesTamperedCachedAssetconfirms the cached file is removed when the checksum mismatches. Per the coding guideline on negative-path tests for recovery logic, it would be nice to also cover the inverse: when the cached asset's checksum matches, the cached file is preserved acrossinstallFromTool.TestInstallFromTool_VerifiesChecksumBeforeExtractionexercises the success path but doesn't assert the cached file still exists afterward, so a small explicit assertion (or a dedicated subtest seeding a valid cache + sidecar) would lock in the "do not delete on match" contract.As per coding guidelines: "Include negative-path tests for recovery logic: whenever a test verifies that a recovery/fallback triggers under condition X, add a corresponding test verifying the recovery does NOT trigger when condition X is absent."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/toolchain/installer/verification_integration_test.go` around lines 102 - 140, Add a companion positive-path test (or extend TestInstallFromTool_VerifiesChecksumBeforeExtraction) that seeds the cache with a valid asset and sidecar pointing to a test server serving a checksums.txt whose sha256 matches the cached file, then call Installer.installFromTool (use the same Installer struct and registry.Tool shape as in TestInstallFromTool_RemovesTamperedCachedAsset) and assert no error and that cachedPath still exists (check cacheSourceURLPath as needed); ensure you compute and write the correct checksum string into the server response so verification passes and reference cachedPath, cacheSourceURLPath, Installer.installFromTool, and the existing test names when adding the new test.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@pkg/toolchain/installer/verification_integration_test.go`:
- Line 117: The test is hand-writing the cache sidecar format instead of using
the production writer; change tests to call the same writer so format stays in
sync by adding a small test helper (e.g., a package-private
seedCacheSourceURL(t, cachedPath, url) or reuse writeCacheSourceURL) and update
tests like verification_integration_test.go to call that helper instead of
directly writing url+"\n" to cacheSourceURLPath(cachedPath); ensure the helper
uses the existing writeCacheSourceURL implementation so all tests share the
single source of truth for the on-disk sidecar format.
- Around line 102-140: Add a companion positive-path test (or extend
TestInstallFromTool_VerifiesChecksumBeforeExtraction) that seeds the cache with
a valid asset and sidecar pointing to a test server serving a checksums.txt
whose sha256 matches the cached file, then call Installer.installFromTool (use
the same Installer struct and registry.Tool shape as in
TestInstallFromTool_RemovesTamperedCachedAsset) and assert no error and that
cachedPath still exists (check cacheSourceURLPath as needed); ensure you compute
and write the correct checksum string into the server response so verification
passes and reference cachedPath, cacheSourceURLPath, Installer.installFromTool,
and the existing test names when adding the new test.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 6413bc06-ad53-41d8-af0d-aef9c45f5e2c
📒 Files selected for processing (3)
pkg/toolchain/installer/download.gopkg/toolchain/installer/download_test.gopkg/toolchain/installer/verification_integration_test.go
|
Warning Release Documentation RequiredThis PR is labeled
|
|
These changes were released in v1.220.0-rc.0. |
what
pkg/toolchain/verificationfor Aqua-compatible checksum, signature, and attestation verification before tool extraction.why
references
go test ./pkg/toolchain/installer ./pkg/toolchain/... ./cmd/toolchain/...scripts/run-custom-golangci-lint.shSummary by CodeRabbit
New Features
Bug Fixes
Documentation