Skip to content

feat(docker)!: generated InfluxDB credentials, unprivileged web image, and retention margin - #972

Merged
Starosdev merged 15 commits into
betafrom
feat/965-images-influx-retention
Oct 13, 2026
Merged

Starosdev merged 15 commits into
betafrom
feat/965-images-influx-retention

Conversation

@Starosdev

@Starosdev Starosdev commented Oct 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

WP-C (images, InfluxDB bootstrap, retention) for the 2.0.0 release. InfluxDB admin credentials are generated at first setup instead of using published defaults, the web image runs as an unprivileged user, default retention leaves margin for a missed downsample run, the collector image gains a healthcheck, and the example deployments match the 2.0 auth default.

Stacked on #971 (security defaults): this branch contains #971's commits until that PR merges. Review only the commits not on feat/965-security-defaults. It targets beta so the Docker build and permission checks run.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)
  • CI/CD or infrastructure change

Related Issues

Related to #965. Depends on #971.

Changes Made

  • InfluxDB credentials: web.influxdb.token and init_password default to empty. On a fresh Influx, Scrutiny generates both with secrets.EnsureSecret, stores .influxdb-token and .influxdb-password (0600) in web.secrets.dir, and onboards with them. Values are never logged. An explicitly configured token or password is used as given. For an already onboarded Influx the order is: configured token, saved .influxdb-token, then the legacy scrutiny-default-admin-token with a rotation warning, so existing installs keep working. A fresh setup with an unwritable config dir fails at startup naming web.influxdb.token.
  • Retention: default retention.daily 15 to 21 days and retention.weekly 9 to 13 weeks, so one missed weekly or monthly downsample run loses no history. EnsureBuckets applies the new retention to existing buckets at start when retention_policy is true; custom values are kept.
  • Web image runs as an unprivileged user (breaking): entrypoint-web.sh starts as root, changes ownership of /opt/scrutiny/config and /opt/scrutiny/reports to PUID:PGID (default 1000:1000), then drops privileges with setpriv. Root-owned volumes from 1.x are handed over automatically; PUID=0 keeps root. Collector and omnibus images stay root (raw device access; omnibus runs Influx, web, cron, and collectors under one supervisor).
  • Collector image: HEALTHCHECK (cron running, optional COLLECTOR_HEALTHCHECK_MAX_AGE_HOURS) and a run-state file touched after each successful run. Plain collector image only.
  • Examples (breaking for copied examples): InfluxDB port 8086 is no longer published. The hub/spoke compose requires SCRUTINY_AUTH_TOKEN, mapped to SCRUTINY_WEB_AUTH_TOKEN and COLLECTOR_API_TOKEN. Unraid templates gain token fields and the omnibus template drops port 8086.
  • Docs: docs/UPGRADE_2.0.md sections for InfluxDB credentials, retention, and the web image user; DOWNSAMPLING.md, DEPLOYMENTS.md, TROUBLESHOOTING_INFLUXDB.md, README, example.scrutiny.yaml, TESTING.md.

Testing

  • I have tested this locally
  • I have added/updated tests that prove my fix/feature works
  • All existing tests pass

go build ./..., go vet ./..., go test ./... pass; golangci-lint run --new-from-rev (v2.14.0, linux/amd64) 0 issues; shellcheck clean on new scripts; compose YAML and Unraid XML parse; docker/tests/image-matrix_test.sh passes. Influx credential tests use a fake Influx server: fresh setup, configured token, onboarded instance, legacy fallback warning, unwritable dir. A retention margin test pins the defaults.

Not verified locally (no Docker available): image builds, setpriv and find in the base image, COPY --chmod, the HEALTHCHECK, the root-owned volume handover (docker/tests/frontend-permissions_test.sh was extended but not run), and a real Influx onboarding. This PR's Docker CI checks are the first real run.

Checklist

  • My code follows the project's code style
  • I have performed a self-review of my code
  • I have commented my code where necessary (particularly complex areas)
  • I have updated the documentation if needed
  • My changes generate no new warnings

Notes

Review: required (changes container privileges and credential bootstrap)

web.influxdb.token and web.influxdb.init_password no longer default to the
public values scrutiny-default-admin-token and password12345. On first
InfluxDB setup Scrutiny generates both, onboards with them, and saves them
under web.secrets.dir (.influxdb-token, .influxdb-password, mode 0600). A
configured token or password is used as given.

An InfluxDB that is already onboarded keeps working: Scrutiny uses the
configured token, then the saved token, then falls back to the legacy default
token that earlier releases used, and logs a warning that recommends
rotation. Secret values are never logged. The setup check now runs before the
client is built so the generated token is the one the client uses.
…es nothing

The weekly task reads data 7 to 14 days old but the metrics bucket kept only
15 days, so one missed Sunday run lost a week of history. Default daily
retention is now 21 days and weekly retention 13 weeks, which gives the
weekly and monthly tasks a week or more of margin. EnsureBuckets already
applies configured retention to existing buckets on start, so installs on the
defaults pick this up automatically.
The web entrypoint starts as root only to chown /opt/scrutiny/config and
/opt/scrutiny/reports to PUID:PGID (default 1000:1000), then drops privileges
with setpriv. Config volumes created as root by earlier releases are handed
over automatically. PUID=0 keeps root; a container already started as non-root
or without CAP_SETUID runs unchanged. Collector and omnibus images stay root
because they need raw device access.

BREAKING CHANGE: the web image now runs the server as uid 1000 (PUID/PGID) and
changes the owner of files in the config volume. Set PUID=0 to keep running as
root; volumes that refuse chown must be made writable by PUID:PGID.
The check passes while cron runs. Successful collections touch /tmp/scrutiny-collector-last-run; COLLECTOR_HEALTHCHECK_MAX_AGE_HOURS optionally fails the check when that file is too old.
… token in examples

Example compose files, the README commands, and the Unraid templates no
longer publish port 8086. The hub/spoke example and the Unraid web and
collector templates now carry the auth token that the web server requires;
the omnibus token stays optional because the container generates one.

BREAKING CHANGE: example deployments no longer expose InfluxDB on port 8086.
Existing deployments keep their current port mappings.
@Starosdev Starosdev added security Security vulnerabilities and fixes docker Docker/container related labels Oct 13, 2026
In the omnibus container a token set through SCRUTINY_WEB_AUTH_TOKEN stops the server writing .auth-token, so the bundled collectors got 401 or read a stale file. Precedence is now collector config, COLLECTOR_API_TOKEN, SCRUTINY_WEB_AUTH_TOKEN, then the generated file.
Use chown -h so symlinks are not followed, and drop with no_new_privs, no inheritable capabilities, and an empty bounding set (all flags exist in util-linux setpriv).
…xDB in README

The collector templates marked the token required while saying it can be blank when auth is off; the flag is now optional. The README hub/spoke command puts InfluxDB on a Docker network instead of publishing 8086.
…nt cap_drop behavior

On a 401 from an onboarded InfluxDB the log names whether the token came from config, the saved file, or the legacy default, never the value. UPGRADE and DEPLOYMENTS now state that cap_drop ALL needs user: PUID:PGID or CHOWN, SETUID, SETGID.
…x-retention

# Conflicts:
#	collector/pkg/config/config_test.go
@Starosdev
Starosdev merged commit 3817935 into beta Oct 13, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docker Docker/container related security Security vulnerabilities and fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant