Repository navigation
Per-node osquery flags overrides - #1093
Merged
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.
Per-node osquery flags overrides
Follow-up to per-node configuration overrides (#1091). Needs the companion osctrld change, which sends the host's identity and guards restarts. Either side can be deployed first.
Problem
During an investigation, operators need one host to collect more than its environment: file integrity monitoring, process events, other evented tables. Much of that is switched on by startup flags (
--disable_events=false,--enable_file_events=true,--audit_allow_process_events=true, …). Remote configuration can't set them, so configuration overrides can't reach them, and changing the environment's flags changes every node.What changes
Admins of a node's environment can now set a flags override for that node only. It is merged on top of the environment's flags and reaches the host through osctrld, which writes the flagfile and restarts osqueryd.
Node page (SPA)
options, which can take precedence.osctrl-api
GET/PUT/DELETE /api/v1/nodes/{env}/node/{uuid}/flags, reusing the configuration override's target resolution:AdminLevelon the node's environment, with denials audited viadenyEnv;conflicts;osctrld: last fetched, the apply result and error as reported by the host, andrejected_current.rejected_currentis true only when the override exists, hasn't expired, and the rejection is newer than the override's last update. Host-reported times are capped at the server's last-fetch time.osctrl-tls (osctrld endpoints)
FlagsRequestgains optionaluuidandapplyfields.uuidis a valid UUID of a node in that environment. The handler then records the fetch and merges that node's active override into the flags returned byosctrld-flagsandosctrld-verify. An active override is unexpired and saved for the node's current environment.applyinput: recorded only withresult=ok|rejectedand a 64-hex SHA-256. A malformed block is dropped, and the fetch is still recorded.uuid, an unknown node, or a node of another environment gets exactly today's response.pkg/nodeconfigValidateFlagsOverride:--name,--name=value, or the single-dash forms), with#comments and blank lines allowed;tls_,config_,logger_tls_,distributed_tls_,enroll_;config_plugin,logger_plugin,distributed_plugin,disable_distributed,disable_enrollment,disable_reenrollment,host_identifier,specified_identifier,flagfile,database_path,db_path, the carver endpoints,proxy_hostname,read_max,force;no<name>form of each.MergeFlags: byte-stable for the same inputs, so osctrld never restarts osquery for nothing. An override flag replaces every environment line with that name in place, keeping its dash prefix. New flags are appended in override order.FlagOptionConflicts: override flags that also appear in the environment configuration's or the node's configuration override'soptions.FlagsManager: tablenode_flags_overrides, cacheosctrl:nodeflags:<uuid>, with its own expiry and removal, separate from configuration overrides.SET NX; if Redis fails, the override is read from SQL. The configuration override's API, cached JSON, keys and behaviour are unchanged, and its tests are untouched.node_osctrld_status(last fetched, apply result, SHA-256, error, apply time). Upserted per fetch; the error is capped at 1 KiB.Security and operational impact
PUTandDELETE. Denials and changes are audited. A node from another environment returns 404, and a node can't be targeted by setting its hostname to another node's UUID.node_flags_overrides,node_osctrld_status) with explicit, distinct index names. No changes to existing tables.Validation
go test ./... -count=1: 56 packages passgo vet ./...;gofmt -l pkg cmd(empty);golangci-lint run ./...: 0 issuesmake openapi-check: cleancd frontend && npm test: 66 files, 522 tests pass;npm run check: cleanpkg/nodeconfig:noforms anddb_path;FlagsManagercache protocol: cached absence, a refill never overwriting a newer write, SQL fallback, expiry, wrong environment;cmd/tls/handlers:uuid;cmd/api/handlersandcmd/cli:rejected_currentincluding the future-time and expired cases;