Webhook icon
Schedule icon
WorkingDirectory icon
Commands icon
Docker icon
Script icon
If icon
Create icon
SlackIncomingWebhook icon
Log icon

Diff Endpoint osquery Configs Against the Blessed Baseline

Diff an endpoint osquery configuration snapshot against the blessed baseline, file a GitHub issue listing every drifted key, and keep evidence fresh.

Categories
Infrastructure

An endpoint tightens its schedule interval, drops a file path glob or picks up a hand edited pack, and the osquery config walks away from the blessed baseline with nothing to catch it. This blueprint takes one config snapshot from the fleet collector, diffs it key by key against the baseline kept in the flow inside a shared workspace, and turns every changed, missing or unexpected key into a tracked issue, a Slack alert and a dated execution record that doubles as the compliance evidence.

How it works

  1. post_config_snapshot (io.kestra.plugin.core.trigger.Webhook, keyed with the OSQUERY_WEBHOOK_KEY secret) accepts the snapshot after each config pull; daily_drift_sweep (io.kestra.plugin.core.trigger.Schedule, cron 0 4 * * *) ships disabled: true until an operator switches it on.
  2. config_workspace (io.kestra.plugin.core.flow.WorkingDirectory) opens one shared directory. write_snapshot (io.kestra.plugin.scripts.shell.Commands on the Docker runner, image python:3.12-slim) writes the posted body, or the config_snapshot input default on manual runs, into config_snapshot.json with a quoted heredoc, and diff_against_baseline (io.kestra.plugin.scripts.python.Script) reads exactly that file. Both children are scripts inside the workspace and every notification sits after the block, because default tasks are stateless and a temp dir is purged when a task completes.
  3. diff_against_baseline flattens the snapshot into dot paths, compares every blessed baseline key such as schedule.system_info.interval and file_paths.system_binaries, flags baseline keys that went missing and snapshot keys that are not in the baseline, and prints compliant, drift, or error as one ::{"outputs": ...}:: line.
  4. gate_config_drift (io.kestra.plugin.core.flow.If) escalates drift into open_drift_issue (io.kestra.plugin.github.issues.Create) and alert_drift (io.kestra.plugin.slack.notifications.SlackIncomingWebhook), an error run routes through check_snapshot_error and alert_unreadable_snapshot, and a clean endpoint lands in log_compliant. The flow level errors handler reports any workspace or script failure with the execution id.

What you get

  • One gateable verdict, compliant, drift, or error, that any config management pipeline can branch on.
  • The drifted dot paths and a human summary as typed outputs, ready for evidence packs and dashboards.
  • Escalation where engineers already work, a labeled GitHub issue listing every drifted key plus a Slack alert naming the endpoint.
  • A fail safe posture, an unreadable snapshot escalates instead of reading as compliance.
  • An execution history that keeps the exact snapshot diff run after run, not a screenshot in a ticket.

Who it's for

  • Endpoint and platform operators who own the blessed osquery config across a mixed fleet.
  • Security and compliance engineers who need dated evidence that endpoints still match the baseline.
  • IT administrators who want drifted configs tracked as issues instead of discovered during an audit.

Why orchestrate this with Kestra

osquery can dump what an endpoint runs but never says whether that still matches the blessed config, so drift waits for an auditor with a spreadsheet. Kestra supplies the keyed webhook for the collector, the baseline living next to the diff in one file, a shared workspace where the snapshot and the comparison agree on one path, a branch that separates drift from unreadable from clean, GitHub and Slack routing from a single definition, and an execution history per endpoint. A scheduled script on the collector gives you none of that, it only diffs the endpoints someone remembers to point it at.

Prerequisites

  • A worker with Docker access, both workspace children run in python:3.12-slim.
  • A collector step that POSTs the endpoint's effective osquery config as a JSON object, for example assembled from Fleet or a scheduled osqueryi dump of the loaded config.
  • A GitHub token that can open issues in github_repository, classic repo scope or fine grained Issues write.
  • A Slack incoming webhook for the drift alert, the unreadable snapshot alert and the failure handler.

Secrets

  • OSQUERY_WEBHOOK_KEY: key guarding the snapshot webhook URL, anyone holding it can post endpoint config.
  • GITHUB_TOKEN: token used to open the drift issue.
  • SLACK_WEBHOOK_URL: Slack incoming webhook URL used by the drift alert and the errors handler.

Quick start

  1. Add the three secrets and point github_repository at a repository where issues are welcome.

  2. Run the flow once with the default inputs and confirm verdict is drift with drift_count at 4, the fixture tightens the interval, drops a glob, leaves options.logger_plugin out and adds a hand rolled pack.

  3. POST a snapshot that matches the baseline and watch verdict flip to compliant with drift_keys empty in the outputs.

    curl -X POST -H "Content-Type: application/json" -d '{"schedule":{"system_info":{"interval":300,"query":"select uuid, hostname from system_info"},"pack_events":{"interval":60}},"options":{"logger_plugin":"syslog"},"decorators":{"load":["select uid, username from users where uid < 500"]},"file_paths":{"system_binaries":["/usr/bin/%","/bin/%"]}}' "https://<kestra>/api/v1/<tenant>/executions/webhook/<namespace>/osquery-endpoint-config-drift-audit/<OSQUERY_WEBHOOK_KEY>"
    
  4. Point the fleet collector at the webhook and enable daily_drift_sweep once every endpoint reports through it.

How to extend

  • Grade a second estate by adding a baseline_file input written next to the snapshot, so staging and production keep their own blessed configs.
  • Fan the audit across endpoints with io.kestra.plugin.core.flow.Loop over an endpoint list, each subflow posting its own snapshot.
  • Keep the last drift keys in the Kestra KV store and open the issue only for keys that are new since the previous run, so a standing exception does not re-file every night.
  • Stop the endpoint's config pipeline by adding io.kestra.plugin.core.execution.Fail under gate_config_drift.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.