Security & Robustness Improvements#57
Open
solarisfire wants to merge 1 commit into
Open
Conversation
This release focuses on hardening, correctness, and operator clarity while **preserving all existing behaviour**, data formats, and upload cadence. --- ### JSON handling #### Changed - All JSON payloads are now constructed using `jq` instead of shell string concatenation. #### Why - Prevents malformed JSON when upstream commands return partial output, non-JSON text, or unexpected characters. - Ensures all values (API key, server names, telemetry data) are safely escaped. - Eliminates injection and formatting edge cases. #### Behaviour - Payload schema and content remain unchanged when inputs are valid. --- ### Ping server handling #### Changed - Server lists are parsed safely and robustly: - Supports both JSON arrays and whitespace-separated responses. - Server entries are handled as complete strings rather than shell-split tokens. - Server strings are used directly as JSON object keys via `jq`. #### Why - Avoids shell word-splitting bugs. - Prevents malformed JSON if server names contain special characters. - Makes the script resilient to future API format changes. #### Behaviour - Ping logic, parallelism, and results are unchanged. --- ### curl hardening #### Changed - Introduced shared `curl_json` and `curl_post_json` helpers with: - Explicit connection and total timeouts - Retry logic for transient network failures - Proper failure on HTTP error responses - Consistent headers and compressed transfers #### Why - Ensures network failures fail fast and predictably. - Prevents silent success on HTTP 4xx/5xx responses. - Centralises network behaviour for consistency. #### Behaviour - Endpoints, payloads, and timing remain unchanged. --- ### Script locking #### Changed - Replaced PID file logic in `/tmp` with an advisory lock using `flock`. #### Why - Avoids stale PID files after crashes or power loss. - Prevents accidental concurrent execution. - Removes reliance on predictable temporary filenames. #### Behaviour - Single-instance enforcement remains unchanged. --- ### Dishy telemetry collection #### Changed - `grpcurl` execution now: - Uses `timeout -k` to guarantee termination - Explicitly closes stdin to avoid blocking edge cases - Validates JSON output before accepting it - Provides clear console feedback on completion #### Why - Prevents perceived hangs during Dishy data collection. - Ensures misbehaving gRPC calls cannot stall the main loop. - Improves operator visibility without changing logic. #### Behaviour - Collection frequency and data content remain unchanged. --- ### Upload execution #### Changed - Removed invalid use of `timeout` around shell functions. - Relied on curl’s built-in timeout controls instead. #### Why - `timeout` can only execute external binaries, not shell functions. - Curl already enforces strict execution limits. #### Behaviour - Upload timing and failure handling remain unchanged. --- ### Validation and execution safety #### Changed - Enabled `set -euo pipefail`. - Added validation for interval arguments. - Ensured optional data sections always produce valid JSON objects. #### Why - Prevents undefined variables and partial state propagation. - Ensures failures are detected early and handled cleanly. - Improves long-running stability. #### Behaviour - Normal operation remains unchanged. - Errors now fail fast and explicitly. --- ### Explicitly unchanged behaviour - Low-resolution upload cadence (epoch-aligned modulo timing) - High-resolution upload cadence (15-second alignment) - Command-line API key usage - Parallel ping behaviour - Data schema sent to `starlinkstatus.space` ---
Owner
|
Thanks for the PR! Are there new dependencies that are needed for using this new Script? |
Author
|
Thanks! Yes — this update introduces one new required dependency: jq (used to construct the JSON payload safely instead of string concatenation) Everything else is unchanged. The locking mechanism now uses flock, but on Raspberry Pi OS / Debian that comes from util-linux, which is installed by default on basically all systems (so no extra install step in most cases). All existing optional dependencies remain the same: speedtest (only if --speedtest) grpcurl (only if --dishy) GNU parallel (already required) |
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.
This release focuses on hardening, correctness, and operator clarity while preserving all existing behaviour, data formats, and upload cadence.
JSON handling
Changed
jqinstead of shell string concatenation.Why
Behaviour
Ping server handling
Changed
jq.Why
Behaviour
curl hardening
Changed
curl_jsonandcurl_post_jsonhelpers with:Why
Behaviour
Script locking
Changed
/tmpwith an advisory lock usingflock.Why
Behaviour
Dishy telemetry collection
Changed
grpcurlexecution now:timeout -kto guarantee terminationWhy
Behaviour
Upload execution
Changed
timeoutaround shell functions.Why
timeoutcan only execute external binaries, not shell functions.Behaviour
Validation and execution safety
Changed
set -euo pipefail.Why
Behaviour
Explicitly unchanged behaviour
starlinkstatus.space