## Overview `dibble` is a one-stop CLI for seeding a Fleet server with test data — users, teams, policies, reports, labels, scripts, MDM profiles, software, secrets, CAs, and vulns — replacing ~8 ad-hoc seeding tools with a single binary. It makes it easy to: - **Spin up a populated dev/test server in one command** — `dibble all` plants everything with sensible, idempotent defaults. - **Skip the flag-memorization** — running `dibble` with no args launches an interactive wizard that prompts for Fleet URL, API token, theme, and which entities to seed, and offers to save the config to `~/.dibble.yaml`. - **Seed individual entity types** — `dibble users`, `dibble teams`, `dibble policies`, etc., when you only need one slice. - **Get themed, recognizable test data** — pick a theme (hitchhikers, tng, lotr, ghibli, parksrec, …) so seeded names are easy to eyeball in the UI. Hosts are intentionally out of scope — `cmd/osquery-perf` still owns that. `dibble hosts` is a thin convenience wrapper that picks a fleet, fetches its enroll secret, and prints/runs the osquery-perf invocation for you. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Dibble: a CLI tool to seed realistic test data, including an interactive wizard and subcommands for teams/users/software/policies/scripts/reports/profiles/labels/activities/enroll-secrets/hosts/vulns, plus theme-driven “cas” and “ping”. * Theme system: multiple curated themes to generate consistent seeded identities, policies, software, labels, and scripts. * **Chores** * Ignored the built dibble binary and added a Makefile build target to compile the dibble tool. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
42 lines
1.2 KiB
Go
42 lines
1.2 KiB
Go
package seed
|
|
|
|
import (
|
|
"github.com/fleetdm/fleet/v4/tools/dibble/pkg/themes"
|
|
)
|
|
|
|
// Labels seeds dynamic (query-based) labels. Manual labels require live host
|
|
// identifiers, which dibble can't synthesize meaningfully — those should be
|
|
// created against a Fleet populated by osquery-perf.
|
|
func Labels(c Client, log Logger, theme themes.Theme, count int) Result {
|
|
res := Result{Entity: "labels"}
|
|
|
|
labelQueries := []string{
|
|
"SELECT 1 WHERE 1=0;",
|
|
"SELECT 1 FROM osquery_info;",
|
|
"SELECT 1 FROM os_version WHERE platform = 'darwin';",
|
|
"SELECT 1 FROM os_version WHERE platform = 'windows';",
|
|
"SELECT 1 FROM os_version WHERE platform IN ('ubuntu','rhel','centos','debian');",
|
|
}
|
|
|
|
for i := 0; i < count; i++ {
|
|
n := themes.Pick(theme, "label", i)
|
|
body := map[string]any{
|
|
"name": n.Name,
|
|
"query": labelQueries[i%len(labelQueries)],
|
|
"platform": "",
|
|
"description": "Seeded by dibble — " + n.Name,
|
|
}
|
|
err := c.Post("/api/latest/fleet/labels", body, nil)
|
|
switch {
|
|
case err == nil:
|
|
res.Created++
|
|
log.Printf("label %q", n.Name)
|
|
case IsAlreadyExists(err):
|
|
res.Skipped++
|
|
default:
|
|
res.Errors = append(res.Errors, err)
|
|
}
|
|
}
|
|
return res
|
|
}
|