Skip to content

feat: install drivers from HTTP URL templates in dbc.toml - #621

Open
eitsupi wants to merge 25 commits into
feat/lock-measure-hash-onlyfrom
feat/http-source
Open

eitsupi wants to merge 25 commits into
feat/lock-measure-hash-onlyfrom
feat/http-source

Conversation

@eitsupi

@eitsupi eitsupi commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Let projects install off-registry dbc packages using HTTP URL templates in dbc.toml (see #394).

[drivers.example]
version = "1.2.0"
source = {
  type = "http",
  url = "https://example.com/releases/download/v{version}/example_{os}_{arch}_v{version}.tar.gz",
  checksum_url = "https://example.com/releases/download/v{version}/SHA256SUMS",
  signing_key = false,
}
  • Configuration: Requires a dbc package archive. URL templates support {version}, {os}, and {arch} in the path. dbc does not discover available versions, so version must be a full version ("1.2.0" or "=1.2.0"); {version} expands to it, including any prerelease or build metadata. Unknown HTTP source keys are errors. An HTTP source can name a key from the project's [signing_keys] (feat: share project signing keys across sources #620), use the built-in key by default, or opt out with signing_key = false. Registry sources reject signing_key and checksum_url.
  • Hashes: Locks archives for the declared platforms, or the current platform by default. dbc reads new hashes from checksum_url when set. Otherwise, it records the first download's SHA-256 and size. As in refactor: let dbc lock pin measured archives without checking them #623, locking extracts an archive only to check an applicable v1 library checksum. At installation, dbc sync checks the archive, its MANIFEST version, and any required library signature. dbc warns when a new hash comes from a declared plain HTTP URL.
  • Downloads: Archive and checksum requests carry no registry credentials or telemetry IDs. URL replacements apply. The CLI rejects HTTPS-to-HTTP replacements and redirects. DBC_BASE_URL does not affect HTTP sources.
  • Lock replay: Records the template digest and absolute archive URLs. dbc sync rejects a changed source or a recorded URL that no longer matches the template. dbc lock can relock an explicitly changed source subject to signer continuity. Removing the HTTP declaration stops both commands without a registry search.
  • Future work: mise's HTTP backend reads versions from a version_list_url, extracting them with a regex, JSON path or expression, so that latest and version prefixes work. A similar source key would let an HTTP source take a version range; this version of dbc rejects such a key with a hint that a newer dbc may be required.

Note: #616 adds dbc sync --locked, which handles registry sources only. Whichever of the two PRs merges second should extend it to HTTP sources.

@eitsupi
eitsupi added this pull request to stack #619 November 26, 2026 00:02
@eitsupi eitsupi changed the title feat/http source feat: install drivers from HTTP URL templates in dbc.toml Nov 26, 2026
@eitsupi
eitsupi marked this pull request as ready for review November 26, 2026 00:54
@eitsupi
eitsupi requested review from amoeba and zeroshade November 26, 2026 00:54
The signer checks and the description of an unsigned pin are shared
with HTTP sources now, so they say source. A locked HTTP source is
also told apart by its own type rather than as any type but registry.
@eitsupi
eitsupi marked this pull request as ready for review November 26, 2026 06:44

@zeroshade zeroshade left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work. The anonymous download path, the HTTPS-downgrade guards, signer checks before any fetch, template-digest replay and the refusal to fall back to registries all look right, and I found no credential leak. One thing I'd like fixed before merge: gnu, musl and variant targets expand to the same archive URL (inline). The rest are nits.

Also, as the description says, whichever of #616 and #621 merges second needs to extend --locked to HTTP sources. Otherwise checkLockedReplay → replayLock → bind("") would report a misleading "not among the configured registries" trust problem for every HTTP driver.

Comment thread cmd/dbc/http_plan.go
if slices.ContainsFunc(artifacts, func(a lockedArtifact) bool { return a.Target == t }) {
continue
}
u, err := src.url.expand(v, t)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Templates only have {os} and {arch}, so with platforms = ["linux_amd64", "linux_amd64_musl"] (or a _v3 variant) both targets expand to the same URL and get locked to the same archive. Nothing catches it later: the install checks the hash, the MANIFEST version and the signature, but not the platform. A musl machine using the platform override would install the glibc build without any warning. Until per-target overrides or a {libc} variable exist, could HTTP sources reject declared targets with LibC == "musl" or a non-empty Variant? Failing when two declared targets expand to the same URL would also work.

```toml
[drivers.example]
version = "1.2.0"
source = {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newlines and a trailing comma inside an inline table are TOML 1.1 only. go-toml accepts them, but TOML 1.0 tools (taplo and editors built on it, Python tomllib) reject them, so users' editors would flag a config that dbc accepts. Could the example use a [drivers.example.source] sub-table instead? It decodes the same.

Comment thread cmd/dbc/sync_plan.go
// the same source or another one, keeps its signer. Every unsigned source is
// a signer of its own, so a driver pinned to one cannot move to another,
// whatever its type.
func checkSourceContinuity(name string, old, now lockedDriver) error {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: with signing_key = false, any template change (a typo fix, a move to another host) is a new signer, so dbc lock refuses it, and the hint says to delete the whole lockfile, which can bump every other driver. It's consistent with unsigned registries, but a per-driver remedy ("delete this driver's entry") would be much less disruptive here.

Comment thread cmd/dbc/http_source.go
}
lines++
if len(line) < 64 || !isHex(line[:64]) {
return "", errors.New("the checksum file has a line that does not start with a SHA-256 hash")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: only GNU sha256sum output is accepted. BSD tag format (SHA256 (name) = hash, from shasum --tag / sha256sum --tag) and backslash-escaped names hit this message. Naming the expected format here or in the docs would save users some guessing.

This branch was successfully deployed

1 active deployment
snapshot — 471e1d4f Deployed Nov 26, 2026 by eitsupi via snapshot #1391
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants