Skip to content

[DRAFT 2.0] spine: TLS-by-default and plugin-contract behavior changes - #537

Closed
somethingwithproof wants to merge 179 commits into
Cacti:developfrom
somethingwithproof:feat/spine-2.0-behavioral
Closed

[DRAFT 2.0] spine: TLS-by-default and plugin-contract behavior changes#537
somethingwithproof wants to merge 179 commits into
Cacti:developfrom
somethingwithproof:feat/spine-2.0-behavioral

Conversation

@somethingwithproof

Copy link
Copy Markdown
Member

Carved out from #535 per @TheWitness — behavioral changes that affect the plugin state-machine contract (thold, amqp-publisher, boost) land in 2.0, not 1.3.

What's in this PR

A1. TLS-by-default for MySQL (6896444)

Flips DB_UseSSL / RDB_UseSSL default from 0 to 1 (preferred, with graceful fallback). Plugin-observable via connection setup timing and cleartext-required MySQL servers rejecting the handshake.

1.3 behavior (matrix branch): default remains 0, operators opt in via spine.conf.
2.0 behavior (this branch): default is 1, operators opt out explicitly.

Why these items defer

Each change touches one of the plugin contract layers:

  • poller_output write timing or content
  • poller_time row shape
  • host.status transition semantics
  • Default connection / IPC behavior visible to plugins

State-machine RFC

Planning an RFC doc to define the 2.0 contract with @TheWitness:

  1. State machine as it exists today (poller_output, poller_time, host.*)
  2. What each plugin relies on (thold, amqp-publisher, boost, weathermap, syslog, snmpagent, mactrack)
  3. Migration surface (deprecation warnings in 1.3 upgrade script)
  4. 2.0 daemon architecture (event-loop, in-process plugin hooks, streaming output)

Next steps

  • Open RFC PR for state-machine contract doc
  • Implement 1.3 metachar-warning script (cacti_check_shell_metachars.php) for deprecation window
  • Plugin compatibility matrix review

Closes nothing on 1.3; tracking for 2.0 only.

Related: #523 (CMake migration, 1.3), #535 (platform + security + operator tooling, 1.3).

- Add CMakeLists.txt mirroring configure.ac feature checks
- Add config/config.h.cmake.in template for cmake builds
- Add build-cmake-linux CI job (gcc/clang matrix)
- Add build-windows CI job (MSYS2/MinGW-w64, continue-on-error)
- Windows crash dump collection via WER LocalDumps
- Gate -Wall by compiler ID (GNU/Clang vs MSVC)
- Use CMAKE_DL_LIBS instead of hardcoded -ldl
- Parse net-snmp-config --libs into proper NETSNMP_LIBRARIES
- Add SNMP_LOCALNAME compile check for feature parity
- No C source files modified

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
spine.h depends on types from common.h (MYSQL, pid_t, size_t,
pthread types, RESULTS_BUFFER from config.h). Add a compile-time
guard that produces a clear error if spine.h is included without
common.h, rather than cascading type errors.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
strncasecmp() returns 0 on match, but the comparisons used the
raw return value as truthy, inverting the logic. TCP matched
non-TCP strings and vice versa.

Also fix: comparisons against 'hostname' instead of 'token'
(lines 1020, 1032), and strncasecmp length 3 for 4-char strings
"TCP6"/"UDP6" (should be 4).

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
getarg(opt, &argv) advances the argv pointer on each call. Three
successive calls in the --mode handler consumed three argv entries
instead of one, corrupting subsequent argument parsing when using
the space-separated form (--mode online).

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Thomas Vincent and others added 3 commits April 15, 2026 01:15
Adds a thin libaudit wrapper (spine_audit_event) that emits a
USER_CMD record with op=spine-* prefix so auditd filter rules can route
spine events to a dedicated audit pipe. Events wired up at:

  * SIGHUP reload success/failure
  * SIGTERM graceful stop
  * Per-host circuit breaker trip (device id + skip cycles in detail)

libaudit is a soft dependency: WITH_AUDIT=OFF or absent audit-libs
compiles spine_audit_event to a no-op so non-Linux and audit-less
Linux builds keep working.

Signed-off-by: Thomas Vincent <thomas@atconsulting.ie>
…tate"

This reverts commit 2110794.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
BREAKING: DB_UseSSL and RDB_UseSSL default to 1 (preferred) instead of 0.
A spine binary talking to a TLS-capable MySQL/MariaDB server now
negotiates an encrypted channel without operator action.

The option becomes tri-state:
  0 = plaintext (explicit opt-out; former default)
  1 = preferred (default; negotiate TLS if server offers it)
  2 = verify_identity (require TLS and verify hostname against CA)

Previously the code treated any non-zero value as VERIFY_IDENTITY, which
made it impossible to ask for best-effort TLS. The new middle tier closes
that gap without forcing CA bundle distribution on every poller.

Deployments that cannot reach a TLS-capable server (legacy MySQL, plain
TCP inside a trusted L2 segment) must set DB_UseSSL=0 explicitly.

Signed-off-by: Thomas Vincent <thomas@atconsulting.ie>
Comment thread .github/actions/install-apt-deps/action.yml Fixed

@github-advanced-security github-advanced-security AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cppcheck found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

Comment thread src/platform/platform_win.c Fixed
Comment thread src/poller.c Fixed
Comment thread src/poller.c Fixed
Comment thread src/poller.c Fixed
Comment thread src/poller.c Fixed
Comment thread src/ping.c Fixed
Comment thread src/php.c Fixed
Comment thread src/circuit_breaker.c Dismissed
Comment thread src/circuit_breaker.c Dismissed
Comment thread src/circuit_breaker.c Dismissed
…ption

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
platform_sandbox_linux.c used uint64_t in the HAVE_LANDLOCK block
without including <stdint.h>; the missing type caused the add_path_rule
signature to fail to parse, which cascaded into an implicit-declaration
error at the first call site.

spine.c calls prctl() under #ifdef __linux__ but sys/prctl.h was only
pulled in transitively via common.h when HAVE_LCAP is defined; add a
direct conditional include so non-cap builds see the declaration.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
glibc's <features.h> freezes the feature-test bitmap on first inclusion.
platform.h pulls <time.h> and platform_process.h pulls <sys/types.h>,
both of which reach <features.h> before CMake's -D_GNU_SOURCE=1 flag
can take effect in the preprocessor pipeline on clang/Linux. Without
the macro visible at that point, pthread_setname_np and pipe2 remain
undeclared, producing -Werror=implicit-function-declaration failures.

Add a `#if defined(__linux__) && !defined(_GNU_SOURCE)` guard at the
top of each affected TU so the macro is always set before any system
header is included, regardless of include order or compiler.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@somethingwithproof somethingwithproof changed the title [DRAFT 2.0] spine: behavioral changes parked for Cacti 2.0 [DRAFT 2.0] spine: TLS-by-default and plugin-contract behavior changes Jun 10, 2026
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Comment thread .github/workflows/static-analysis.yml Fixed
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@somethingwithproof

Copy link
Copy Markdown
Member Author

Addressed the outstanding security-analysis findings in dd8550f:

  • moved workflow inputs and GitHub context values into quoted environment variables;
  • split apt packages into an argv array before invoking apt-get;
  • made test null checks control flow before dereferences;
  • replaced string-literal boolean assertions with an explicit message assertion;
  • removed the unused PHP parser assignment and unreachable ICMP condition; and
  • handle ICMP send failures instead of overwriting the result.

Validation: actionlint and workflow policy pass; the reported cppcheck patterns are gone; CMake build passes; all 19 CTest tests pass.

@somethingwithproof
somethingwithproof marked this pull request as ready for review August 29, 2026 05:53
@somethingwithproof

Copy link
Copy Markdown
Member Author

Closing in favour of #523.

These branches are not three features. All three independently delete autotools (configure.ac, Makefile.am, Makefile.in, bootstrap), move the sources into src/, and add CMake — and they conflict with each other across 18 to 69 files. This branch shares 89 of #523's commits, so it is a fork of an older #523 head rather than independent work.

The TLS work here is worth keeping and I will bring it back separately: the bool/my_bool width fix at the MYSQL_OPT_SSL_VERIFY_SERVER_CERT boundary, the missing mysql_ssl_set(), and the mysql_get_ssl_cipher() downgrade check are bug fixes that belong on 1.2.x, distinct from the 2.0 default flip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants