Serve the osquery package digest and honor the configured version in verify - #1055
Merged
Conversation
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.
Serve the osquery package digest and honor the configured version in verify
Two changes to
POST /{env}/verify, the endpoint osctrld polls for what it should install.osquery_sha256in the verify responseosctrld#22 refuses to install an osquery package it cannot verify, and reads the digest from
VerifyResponse.OsquerySHA256(json:"osquery_sha256") before falling back to its own--osquery-sha256. osctrl did not send that field. It does now, sourced from a newosquery.sha256setting, so nodes on that branch start verifying downloads with no client change.Set it only on a uniform fleet. osquery ships a different artifact per format and architecture — deb amd64/arm64, rpm x86_64/aarch64, the macOS pkg, the Windows msi — and osctrld builds its download URL from its own
runtime.GOOS/GOARCHwithout telling the server which one it will fetch. One scalar digest can therefore only be right for a deployment that installs a single package. Empty is the default and is safe, not a downgrade: osctrld then uses its own flag, or refuses. Returning a digest would make five of six platforms fail closed on a mismatch.The complete fix for mixed fleets is small and spans both repos: osctrld sends its package format and arch on verify, osctrl keys digests by
deb-amd64,rpm-x86_64,pkg,msi. Worth a follow-up issue against osctrld#22 — the server half is then a map lookup in the helper this PR adds.--osquery-versionhad no readerThe flag is documented as "Version of osquery to be used" and
params.Osquery.Versionwas populated at boot and consumed by nothing. Pinning a version in config or env changed nothing: verify handed every node the compile-timeversion.OsqueryVersion, and since that value is what osctrld installs and upgrades to, the whole fleet quietly tracked whatever osctrl was built against.osqueryVersion()now resolves configured → trimmed → build-time fallback. The fallback matters: an empty string reaches osctrld'sosqueryInstallDecision, which treats an unparseable side as "unknown" and reinstalls, so an operator with no pin would get reinstall churn rather than today's behavior.The five package-filename call sites keep using the build constant (the MSI one moved onto it, so it stops being the odd one out). Those label a
.deb/.msiosctrl didn't build — naming them after a config pin would make the label wrong in a new way.Files
pkg/types/types.goOsquerySHA256onVerifyResponse, tag matching osctrld verbatimpkg/config/types.goosquery.sha256settingcmd/tls/handlers/handlers.goosquerySHA256()andosqueryVersion(), both nil-safe and trimmedcmd/tls/handlers/post.godeploy/config/tls.ymlcmd/tls/handlers/verify_sha256_test.goNot added to
api.yml: osctrl-api never serves/verify, so the knob would be dead config there.Tests
Config path, whitespace trimming (a digest pasted into YAML picks up newlines and neither side trims before comparing), both empty cases including a nil config, the version fallback chain, and a wire-format guard — renaming
osquery_sha256silently disables verification on every node, so that one is pinned explicitly.go build ./...clean;cmd/...,pkg/types,pkg/configgreen. No OpenAPI regen:VerifyResponseis a TLS endpoint and doesn't appear in the API spec.