Repository navigation
feat: add dbc lock to update the lock file without installing - #575
Conversation
InspectPackageArchive accepts WithInspectSignatureVerifier, which runs a PackageVerifier on the private staging directory and manifest in the same extraction pass, before any digest is returned. This lets callers check a package signature without installing the package.
…hecks Move the planning, per-driver fetch loop and lock write of sync into driverListResolution, and the size, hash and library proof checks of a downloaded archive into checkDownloadedArchive, so another command can resolve a driver list with its own per-driver step. Sync behaviour is unchanged.
dbc lock resolves the driver list like dbc sync, keeping compatible pins and upgrading v1 lock files, but installs nothing. An archive is downloaded only when the registry publishes no hash for the current platform or a v1 library checksum has to be checked; its signature is verified before its hash is recorded unless --no-verify is set, and the download is removed afterwards. The lock file is written only after every driver succeeded.
With --no-verify, dbc lock recorded the SHA-256 of a downloaded archive without extracting it, so a malformed archive could be pinned. Always extract it with the install-time safety checks and skip only the signature verification. Also test that dbc lock writes the same lock file as dbc sync and that it replays a complete lock file without contacting the registry.
…h sync Replace the no-op verifier that forced dbc lock to extract downloaded archives with explicit archiveChecks, and share the download step (downloadArchive) and the Columnar signature verifier (columnarSignatureVerifier) between dbc sync and dbc lock. Sync now detects signature failures through the error chain instead of a flag; its behaviour and messages are unchanged.
dbc lock to update the lock file without installing
zeroshade
left a comment
There was a problem hiding this comment.
Looks good. Pulling driverListResolution.resolve out of sync is clean, sync and lock now differ only in the per-driver fetch step, and signatureVerificationError is a nice replacement for the verificationFailed closure flag. I built it and tried it: dbc lock writes a v2 lock with per-platform artifacts, and a failed run leaves the existing lock file unchanged.
A few small things:
- The
jsonschema.LockStatus.Driverscomment says "in driver list order", butplanner.plangoes throughslices.Sorted(maps.Keys(list.Drivers)), so drivers come out sorted by name. A TOML table has no reliable order to keep anyway, so the comment should say sorted by name. dbc lockpicks each driver's version and artifact for the host platform (config.PlatformTuple()). Locking on a Linux CI runner therefore fails for a driver that has no Linux build, even though the lock file also records artifacts for other platforms. Since the docs suggestdbc lockfor CI,cli.mdshould say this. A--targetoption could be a follow-up alongside--upgrade.- Nit: the
checksum_failederror-code mapping is now repeated insyncModel.UpdateandlockModel.Update. A shared helper would keep the two from drifting. - Nit: pressing Ctrl-C during
dbc lockexits 0 without writing anything, becausebaseModelquits without setting a status.syncbehaves the same, but for a command meant for CI, an interrupted run that reports success is easy to miss. - Nit: when the registry publishes a hash,
dbc lockpins it without downloading or checking the signature; that happens later, whensyncinstalls. One explicit sentence incli.mdwould avoid the impression thatdbc lockchecks every pinned archive.
Map checksum, size and v1 library mismatches to checksum_failed in one helper used by both commands. Correct the lock.status driver order comment: drivers are sorted by name. Leave a TODO that dbc lock still depends on the host platform.
|
Thanks for the review.
|
zeroshade
left a comment
There was a problem hiding this comment.
Thanks, the follow-ups look good. jsonErrorCode keeps the sync/lock mapping in one place and the existing checksum_failed tests cover both paths; the cli.md sentence on registry-published hashes is clear. Your Ctrl-C explanation checks out (lockModel has no NeedsRenderer, so it runs with tea.WithInput(nil)). For the host-platform limitation, could you open an issue to track the follow-up after #584 rather than relying on the TODO in lock.go? driver_list.md suggests dbc lock for CI, so it'd be good to have it visible. Still LGTM.
|
Thanks, I've opened #592 |
Fixes the failing `Run pre-commit hooks` job on main (https://github.com/columnar-tech/dbc/actions/runs/44146064069). #575 merged after #583 enabled golangci-lint with `--fix`, and its CI ran before that, so the modernizer rewrite of `errors.As` to `errors.AsType` in `checkDownloadedArchive` was never applied. This is the hook's own output. Verified locally: `pre-commit run --all-files` passes, `go build ./...` and `go test ./cmd/dbc/` pass.
Follow-up to #575 (`dbc lock`). Lockfile v2 pins sources and archive hashes, but not the key signatures are verified with. This PR adds that before v2 ships. - **Lockfile:** each driver requires a `signer` table pinning the OpenPGP primary key its packages must verify with. This records the expected signer, not successful verification. A v2 lock without it is invalid; v2 is unreleased, so there is no migration. v1 upgrades are unchanged. ```toml [drivers.signer] type = 'openpgp' fingerprint = 'ab7766e9b341299ebc7f45dd82abd0a33a3c9e48' ``` - **Enforcement:** `dbc sync` and `dbc lock` verify reused installations, new installations and hash-measuring downloads with the pinned key. An untrusted pin, or a re-resolution that would change the pin, fails before anything is downloaded, installed or written. There is no fallback key. `--no-verify` skips that run's signature check without changing or bypassing the pin. - **API:** `dbc.SigningKey` exposes one key's fingerprint and verification; `dbc.ColumnarSigningKey()` returns the built-in key. `SignedByColumnar` and `VerifyPackageSignature` are unchanged. Only Columnar's built-in key is trusted. Existing users see only the new lock field; `dbc install`, `Client.Install` and install receipts are unchanged. ### Other sources and verification methods The table identifies who must authenticate a release; `type` specifies how. It belongs to the driver release rather than its source: one registry can serve multiple publishers. - **Other OpenPGP keys**, including custom-registry keys, would use `openpgp` with another fingerprint, without format changes. - **Other authentication methods**, such as the Packslip source explored in #497, would need no OpenPGP signature. Another `type` would pin the verified identity (project, issuer and workflow identity for Sigstore keyless signing), so replaying the lock elsewhere does not trust a new identity on first use. Verified metadata hashes stay in `evidence`. This PR defines only `openpgp`. An unknown type makes the lock invalid rather than skipping verification, so new types are additive.
Part of #592. As noted in the review of #575, `dbc lock` required a build for the current platform, so a Linux CI runner could not lock a macOS-only driver. If the selected version has no build for the current platform, `dbc lock` records builds with published archive hashes. It downloads no archives for other platforms and fails if it cannot record any. If an existing entry lacks an artifact for the current platform and the locked version has no build for it, `dbc lock` keeps the entry. Version and registry selection remain independent of the current platform (#584). If the selected version lacks a build for that platform, `dbc sync` fails without switching versions or registries. Upgrading a v1 entry also fails if its library checksum was recorded for the current platform and there is no build to check it against. #608 adds declared platforms to `dbc.toml`.
…623) Align measured hashes with the published-hash path ahead of HTTP URL template sources (#621). - **Background:** #575 checked signatures before pinning measured archives, to catch invalid signatures before saving the lockfile; `--no-verify` skipped that check. After review, it also extracted those archives even with the flag, so that locking would catch malformed tarballs. - **Why change:** A lockfile pins archive bytes and the required signer; it does not prove that every platform's package installs. Installation always verifies the signature with the pinned key, so checking at lock time only reports a bad archive earlier, and a published hash was already pinned without these checks. The checks also cost an extraction for every newly measured platform, which an HTTP source without `checksum_url` needs for every archive. - **Archive hashes:** `dbc lock` and `dbc sync` use the published hash when available and otherwise record the downloaded archive's SHA-256, without extracting it or verifying its signature. An applicable v1 library checksum still requires extracting the current platform's archive. - **Installation:** `dbc sync` checks the archive during extraction and uses the pinned key to verify the driver library's signature when required. The signature covers the library alone. A malformed archive or one with an invalid signature can now be pinned and fail at installation. - **Lock options:** Remove `dbc lock --no-verify` now that signature checks happen at installation or reuse. Both commands still reject a signer that differs from the registry configuration before downloading any archives, even with `dbc sync --no-verify`.
Part of #196. This adds
dbc lock, which creates or updatesdbc.lockfrom the driver list without installing drivers. A follow-up PR will add--upgradeand--upgrade-driver <name>todbc lockto move locked drivers to newer versions within the driver list's constraints, as suggested in #196.dbc lockresolves the driver list the same waydbc syncdoes: compatible pins in an existing lock are kept, v1 lock files are upgraded, and the project lock is held while resolving. Nothing is installed.--no-verifyis set, and only then is its hash recorded; the download is removed afterwards. The lock file is written only after every driver succeeded.config.InspectPackageArchivegainsWithInspectSignatureVerifierso a package signature can be checked without installing. Sync's resolution and downloaded-archive checks are shared withdbc lock; sync behaviour is unchanged.--jsonprints alock.statusobject with the lock file path and the locked drivers.