Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ jobs:
echo "::error::a chart config test skipped"; exit 1
fi
for t in TestChartDefaultsAreTheConfigDefaults TestChartTraceAndStoreValuesReachTheConfig \
TestChartPluginsAreOffByDefault TestChartPluginsValuesReachTheConfig \
TestChartPluginsAreOnByDefaultWithNoKeyAndNoVolume TestChartPluginsValuesReachTheConfig \
TestChartFailoverIsOffByDefaultAndItsValuesReachTheConfig; do
echo "$OUT" | grep -q -- "--- PASS: $t" || { echo "::error::$t did not pass"; exit 1; }
done
Expand Down
26 changes: 14 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -877,9 +877,10 @@ plant, and the memory goes back when it exits. The test proves it the hard way:
the refused candidate has the same Link In, and after the refusal a message
through the running flow's link still arrives.

Three decisions worth knowing. **It's off by default**, because a gate an
operator didn't ask for is a deploy that fails at 3 AM for a reason nobody on
shift has heard of. **Tests that can't run don't pass**: a child that won't
Three decisions worth knowing. **It's on by default.** With no suite beside the
flow file there is nothing to fail and the deploy goes through, saying it wasn't
checked; the day somebody writes a suite, every deploy runs it. Set
`tests.gate: false` to deploy without checking. **Tests that can't run don't pass**: a child that won't
start or a run longer than `tests.timeout` refuses the deploy and says which.
And **rollbacks aren't gated.** A rollback is how somebody gets out of a bad
state, to one that already ran, and holding it up on today's tests is how an
Expand Down Expand Up @@ -1281,8 +1282,9 @@ temp, fsync, rename, fsync the directory, three backups deep, so a power cut
mid-save leaves you the old file or the new one, never half of each. If it ever
reads a corrupt one, it falls back to a backup and says so out loud.

**The discovery nodes are off by default** and bounded by an operator-configured
CIDR allowlist. A hostname that resolves to one in-scope address and one
**The discovery nodes are on by default** and bounded by a CIDR allowlist that
starts as the private ranges a plant floor lives on, and that an operator
replaces with their own networks. A hostname that resolves to one in-scope address and one
out-of-scope address is refused outright, because otherwise DNS is just the way
around the allowlist.

Expand Down Expand Up @@ -2188,12 +2190,12 @@ store:
ackFlush: 100ms # how long a delivered message waits to be marked done; 0s marks each one first

discovery:
enabled: false
allowedCIDRs: [] # enabled with this empty is a startup error
enabled: true
allowedCIDRs: [10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 100.64.0.0/10, fc00::/7, 127.0.0.0/8, "::1/128"] # naming your own replaces these; enabled with this empty is a startup error

exec:
enabled: false
allowedCommands: [] # enabled with this empty is a startup error
enabled: true
allowedCommands: [ping, curl, mbpoll, snmpget, snmpset, snmpwalk, date, hostname, uname, uptime, df, free, ls, cat, grep, jq, echo, "true"] # naming your own replaces these; enabled with this empty is a startup error

files:
allowedPaths: [] # extra trees on top of data.dir, which is always allowed
Expand Down Expand Up @@ -2265,10 +2267,10 @@ Secret.
| `HOTLOOP_FLOW_CONTEXT_PERSIST`, `HOTLOOP_FLOW_CONTEXT_FLUSH_INTERVAL` | Persistent context. `false` turns it off; the interval is a duration such as `30s`. |
| `HOTLOOP_FLOW_TRACE_OTLP_HEADERS` | Headers for the collector, `Name=value` pairs separated by commas, added to any in the file. For an API key that has no business in a ConfigMap. |
| `HOTLOOP_FLOW_DURABLE_MAX_BYTES`, `HOTLOOP_FLOW_DURABLE_ACK_FLUSH` | The disk quota for durable wires, and how long a delivered message waits to be marked done. |
| `HOTLOOP_FLOW_TESTS_GATE` | `true` turns on the [deploy gate](#the-deploy-gate). |
| `HOTLOOP_FLOW_TESTS_GATE` | The [deploy gate](#the-deploy-gate), on by default; `false` turns it off. |
| `HOTLOOP_FLOW_LOG_LEVEL`, `HOTLOOP_FLOW_LOG_FORMAT` | Logging. |
| `HOTLOOP_FLOW_DISCOVERY_ENABLED`, `HOTLOOP_FLOW_DISCOVERY_CIDRS` | Discovery nodes. Comma-separated CIDRs. |
| `HOTLOOP_FLOW_EXEC_ENABLED`, `HOTLOOP_FLOW_EXEC_ALLOWED_COMMANDS` | The exec node. Comma-separated commands. |
| `HOTLOOP_FLOW_DISCOVERY_ENABLED`, `HOTLOOP_FLOW_DISCOVERY_CIDRS` | Discovery nodes, on by default; `false` turns them off. Comma-separated CIDRs replace the default private ranges. |
| `HOTLOOP_FLOW_EXEC_ENABLED`, `HOTLOOP_FLOW_EXEC_ALLOWED_COMMANDS` | The exec node, on by default; `false` turns it off. Comma-separated commands replace the default field tools. |
| `HOTLOOP_FLOW_PLUGINS_DIR`, `HOTLOOP_FLOW_PLUGIN_TRUSTED_KEYS` | Where plugins are, and the publisher keys to trust. Comma-separated keys. |
| `HOTLOOP_FLOW_PLUGIN_GRANTS` | What plugins may use: `name=cap,cap;name=cap`. |
| `HOTLOOP_FLOW_PLUGIN_MAX_MEMORY_MIB`, `HOTLOOP_FLOW_PLUGIN_MAX_TIMEOUT` | The ceilings on a plugin node's memory and per-message time. |
Expand Down
66 changes: 47 additions & 19 deletions charts/hotloop-flow/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,29 @@ bindToInterface:
netRaw: false

# ── Discovery ────────────────────────────────────────────────────────────────
# The scan nodes. Off by default: this is a plant-floor inventory tool, not a
# scanner anybody with edit access can aim anywhere. Enabling it without listing
# the networks it may probe is a startup error, not a licence to scan the world.
# The scan nodes, on. They probe only the networks listed here, which by default
# are the private ranges a plant floor lives on (nothing public), so a scan
# cannot be aimed at the internet from an edit dialog. Name your own networks to
# replace the list. An empty list with discovery enabled is a startup error, not
# a licence to scan the world.
#
# It needs no extra capability: scan only makes TCP connections and netinfo only
# reads the interface list, so the pod keeps every capability dropped either way.
discovery:
enabled: false
allowedCIDRs: []
enabled: true
allowedCIDRs:
- 10.0.0.0/8
- 172.16.0.0/12
- 192.168.0.0/16
- 100.64.0.0/10
- fc00::/7
- 127.0.0.0/8
- ::1/128

# ── The exec node ────────────────────────────────────────────────────────────
# Off by default, and enabling it without listing the commands is a startup
# error rather than a licence to run anything.
# On, with a short list of the field tools a plant flow reaches for. An empty
# list with the node enabled is a startup error rather than a licence to run
# anything. Name your own commands to replace the list.
#
# Node-RED's exec node runs anything, and Node-RED starts with no authentication
# by default. Pilz shipped exactly that on a device and it became CVE-2025-41656
Expand All @@ -161,10 +171,27 @@ discovery:
# the PATH yet is kept and resolved again when a flow uses it, so an init
# container or a mounted volume can supply it after start-up.
exec:
enabled: false
allowedCommands: []
# e.g.
# - /usr/bin/mbpoll
enabled: true
allowedCommands:
- ping
- curl
- mbpoll
- snmpget
- snmpset
- snmpwalk
- date
- hostname
- uname
- uptime
- df
- free
- ls
- cat
- grep
- jq
- echo
- "true"
# Add the commands your plant has, by name or absolute path, e.g.
# - /opt/plant/bin/reset-line

# ── The file nodes ───────────────────────────────────────────────────────────
Expand Down Expand Up @@ -203,11 +230,11 @@ secrets:
allowedPaths: []

# ── Plugins ──────────────────────────────────────────────────────────────────
# Signed WebAssembly plugins, see docs/plugins.md. Off renders nothing, and the
# binary loads nothing. On with no trusted keys, every plugin is refused: a key
# is what you are saying yes to.
# Signed WebAssembly plugins, see docs/plugins.md. On: the plugin directory is
# read and a plugin signed by a key listed under trustedKeys loads. With no
# trusted keys every plugin is refused: a key is what you are saying yes to.
plugins:
enabled: false
enabled: true
# Where plugin directories are read from. Empty means plugins/ inside the data
# directory, or mountPath when a volume is set below.
dir: ""
Expand Down Expand Up @@ -401,10 +428,11 @@ audit:

# ── Flow tests ───────────────────────────────────────────────────────────────
tests:
# true refuses a deploy whose flows fail /data/flows.test.yaml. Off by
# default: a gate nobody asked for fails a deploy at 3 AM for a reason
# nobody on shift has heard of.
gate: false
# true refuses a deploy whose flows fail /data/flows.test.yaml. On: with no
# suite there is nothing to fail and the deploy goes through, saying it was not
# checked; with one, a deploy that fails it is refused, and a rollback is never
# gated. Set false to deploy without checking.
gate: true
timeout: 2m # wall clock for one run of the suite

# ── Authentication ───────────────────────────────────────────────────────────
Expand Down
8 changes: 4 additions & 4 deletions docs/deploying.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,12 @@ On a pod you run yourself, mount the PEM and set `HOTLOOP_FLOW_ASSERTION_PUBLIC_
| `stations.dashboardUrl`, `stations.tenant`, `stations.dashboardTokenSecret.name`, `.key`, `stations.deployTokenSecret.name`, `.key` | empty, empty, empty, `token`, empty, `token` | Push one flow file to every Flow install the tenant runs in EmberNet, with a check after each ([stations.md](stations.md)). All four of the dashboard, the tenant and the two Secret names are set or none is; a render with some of them is refused. Each Secret holds one token and is mounted as a file, never put in the ConfigMap. The deploy token is the one the stations accept and needs `flows.read`, `flows.write` and `status.read`. |
| `failover.urlSecret.name`, `.key`, `failover.name`, `failover.ttl`, `failover.renewEvery`, `failover.writeMargin` | empty, `url`, `flow`, `15s`, a third of the ttl, `5s` | A failover pair: two installs share a lease in a PostgreSQL, one writes to equipment and the other holds its writes until it takes over ([failover.md](failover.md)). Off until the Secret is named. The Secret's key holds the PostgreSQL URL and is mounted as a file, never put in the ConfigMap. |
| `audit.maxBytes`, `audit.keep` | 16 MiB, `4` | When `/data/audit.log` rotates, and how many rotated files stay beside it. |
| `tests.gate`, `tests.timeout` | off, `2m` | `true` refuses a deploy whose flows fail `/data/flows.test.yaml`. Off by default, because a gate nobody asked for fails a deploy at 3 AM for a reason nobody on shift has heard of. |
| `discovery.enabled`, `discovery.allowedCIDRs` | off, empty | The scan nodes. Enabled with an empty list refuses to start. |
| `exec.enabled`, `exec.allowedCommands` | off, empty | The exec node. Same rule. |
| `tests.gate`, `tests.timeout` | on, `2m` | `true` refuses a deploy whose flows fail `/data/flows.test.yaml`. With no suite there is nothing to fail and the deploy goes through. `false` deploys without checking. |
| `discovery.enabled`, `discovery.allowedCIDRs` | on, the private ranges | The scan nodes, bounded by the list. Name your own networks to replace it. Enabled with an empty list refuses to start. |
| `exec.enabled`, `exec.allowedCommands` | on, a short list of field tools | The exec node. Name your own commands to replace the list. Same rule. |
| `files.allowedPaths` | empty | Extra trees the file nodes may reach beyond `/data`. |
| `secrets.mounts` | empty | Secrets to mount read-only, each `{secretName, mountPath}`, for a tls-config's files and `ew_credentialFiles`. Each path joins the secret scope and never the file nodes'. |
| `plugins.enabled` | off | [Plugins](plugins.md). Off renders nothing. On, with `plugins.trustedKeys` empty, every plugin is refused. |
| `plugins.enabled` | on | [Plugins](plugins.md). On, with `plugins.trustedKeys` empty, every plugin is refused. |
| `plugins.trustedKeys`, `plugins.grants` | empty | The publisher keys to believe, and what each plugin may use by name (`clock`, `random`, `context.flow`, `context.global`). A flow using a plugin that asks for more fails the deploy. |
| `plugins.maxMemoryMiB`, `plugins.maxTimeout` | `64`, `5s` | The most memory and the longest time any one plugin node can be given. |
| `plugins.volume`, `plugins.mountPath`, `plugins.dir` | empty, `/etc/hotloop-flow/plugins`, empty | How the plugin files arrive. No volume: copy them into `plugins/` on the data volume. A volume is any Kubernetes volume source (an existing claim, a ConfigMap, a Secret), mounted read-only at `mountPath`, and `dir` follows it. |
Expand Down
18 changes: 13 additions & 5 deletions internal/config/chart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,20 @@ func TestChartHistoryAuditAndTestsValuesReachTheConfig(t *testing.T) {
}
}

// A default render has no plugin settings and no plugin volume, so an instance
// that doesn't use plugins gets exactly the objects it got before they existed.
func TestChartPluginsAreOffByDefault(t *testing.T) {
// A default render has plugins on, with no trusted key (so every plugin is
// refused until a person names one) and no plugin volume: the directory is the
// one inside the data volume.
func TestChartPluginsAreOnByDefaultWithNoKeyAndNoVolume(t *testing.T) {
render := helmRender(t)
if bytes.Contains(render, []byte("plugins:")) || bytes.Contains(render, []byte("name: plugins")) {
t.Errorf("a default render carries plugin settings:\n%s", render)
got := loadRendered(t, configFromRender(t, render)).Plugins
if !bytes.Contains(render, []byte("plugins:")) {
t.Errorf("a default render leaves plugins off:\n%s", render)
}
if len(got.TrustedKeys) != 0 {
t.Errorf("a default render trusts keys %v", got.TrustedKeys)
}
if bytes.Contains(render, []byte("name: plugins")) {
t.Errorf("a default render mounts a plugin volume:\n%s", render)
}
}

Expand Down
57 changes: 42 additions & 15 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,30 @@ type StoreDurable struct {
AckFlush time.Duration `yaml:"ackFlush"`
}

// DefaultDiscoveryCIDRs are the networks the scan nodes may probe when nobody
// has named any: the private ranges a plant floor lives on (RFC 1918, the shared
// 100.64.0.0/10 range overlay networks use, and IPv6 unique local) and this
// machine itself. Nothing public is on it, so a flow cannot aim a scan at the
// internet, and an operator who names their own networks replaces it.
func DefaultDiscoveryCIDRs() []string {
return []string{
"10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16", "100.64.0.0/10",
"fc00::/7", "127.0.0.0/8", "::1/128",
}
}

// DefaultExecCommands are the commands the exec node may run when nobody has
// named any: the field tools a plant flow reaches for, each matched on the
// resolved path of the one on the PATH. There is no shell in the list, so none
// of them can be chained into an arbitrary command, and an operator who names
// their own commands replaces it.
func DefaultExecCommands() []string {
return []string{
"ping", "curl", "mbpoll", "snmpget", "snmpset", "snmpwalk", "date", "hostname",
"uname", "uptime", "df", "free", "ls", "cat", "grep", "jq", "echo", "true",
}
}

// Discovery gates the network discovery nodes.
type Discovery struct {
Enabled bool `yaml:"enabled"`
Expand All @@ -448,8 +472,9 @@ type Discovery struct {

// Exec gates the exec node.
//
// Off by default, and an enabled node with no allowed commands is a
// configuration error rather than "anything goes". In Node-RED nothing sits
// On by default with a short list of field tools (DefaultExecCommands), and an
// enabled node with no allowed commands is a configuration error rather than
// "anything goes". In Node-RED nothing sits
// between "can edit a flow" and "can run any command": the exec node runs
// whatever it is given, through a shell. Put that behind a default with no
// authentication and you get CVE-2025-41656, Pilz shipping Node-RED on a
Expand Down Expand Up @@ -571,13 +596,15 @@ func Default() Config {
Context: StoreContext{Persist: true, FlushInterval: 30 * time.Second},
Durable: StoreDurable{MaxBytes: 256 << 20, AckFlush: 100 * time.Millisecond},
},
Logging: Logging{Level: "info", Format: "text"},
Metrics: Metrics{Enabled: true, Path: "/metrics"},
History: History{Retain: 100},
Audit: Audit{MaxBytes: 16 << 20, Keep: 4},
Tests: Tests{Timeout: 2 * time.Minute},
Plugins: Plugins{MaxMemoryMiB: 64, MaxTimeout: 5 * time.Second},
Failover: Failover{Name: "flow", TTL: 15 * time.Second, WriteMargin: 5 * time.Second},
Logging: Logging{Level: "info", Format: "text"},
Metrics: Metrics{Enabled: true, Path: "/metrics"},
History: History{Retain: 100},
Audit: Audit{MaxBytes: 16 << 20, Keep: 4},
Tests: Tests{Gate: true, Timeout: 2 * time.Minute},
Discovery: Discovery{Enabled: true, AllowedCIDRs: DefaultDiscoveryCIDRs()},
Exec: Exec{Enabled: true, AllowedCommands: DefaultExecCommands()},
Plugins: Plugins{MaxMemoryMiB: 64, MaxTimeout: 5 * time.Second},
Failover: Failover{Name: "flow", TTL: 15 * time.Second, WriteMargin: 5 * time.Second},
Trace: Trace{
Enabled: true, Traces: 256, MaxHops: 512, MaxMessageBytes: 16 << 10, MaxBytes: 16 << 20, PerSecond: 1000,
OTLP: OTLP{ServiceName: "hotloop-flow", Interval: 2 * time.Second},
Expand Down Expand Up @@ -702,8 +729,8 @@ func applyEnv(cfg *Config) {
})
}

if envBool("HOTLOOP_FLOW_TESTS_GATE") {
cfg.Tests.Gate = true
if os.Getenv("HOTLOOP_FLOW_TESTS_GATE") != "" {
cfg.Tests.Gate = envBool("HOTLOOP_FLOW_TESTS_GATE")
}
if envBool("HOTLOOP_FLOW_INSECURE") {
cfg.Auth.Enabled = false
Expand All @@ -712,8 +739,8 @@ func applyEnv(cfg *Config) {
if envBool("HOTLOOP_FLOW_ALLOW_PLAINTEXT_CREDENTIALS") {
cfg.Data.AllowPlaintextCredentials = true
}
if envBool("HOTLOOP_FLOW_DISCOVERY_ENABLED") {
cfg.Discovery.Enabled = true
if os.Getenv("HOTLOOP_FLOW_DISCOVERY_ENABLED") != "" {
cfg.Discovery.Enabled = envBool("HOTLOOP_FLOW_DISCOVERY_ENABLED")
}
if v := os.Getenv("HOTLOOP_FLOW_DISCOVERY_CIDRS"); v != "" {
cfg.Discovery.AllowedCIDRs = splitList(v)
Expand Down Expand Up @@ -747,8 +774,8 @@ func applyEnv(cfg *Config) {
cfg.Plugins.MaxTimeout = d
}
}
if envBool("HOTLOOP_FLOW_EXEC_ENABLED") {
cfg.Exec.Enabled = true
if os.Getenv("HOTLOOP_FLOW_EXEC_ENABLED") != "" {
cfg.Exec.Enabled = envBool("HOTLOOP_FLOW_EXEC_ENABLED")
}
if v := os.Getenv("HOTLOOP_FLOW_EXEC_ALLOWED_COMMANDS"); v != "" {
cfg.Exec.AllowedCommands = splitList(v)
Expand Down
Loading
Loading