Skip to content

Harden telemetry ingestion boundary: no 0.0 fallback, TypeError-proof floatify, guarded timestamps, kalman frame-length check - #207

Draft
mrizvi96 wants to merge 1 commit into
nasa:mainfrom
mrizvi96:206-harden-telemetry-ingestion-boundary
Draft

mrizvi96 wants to merge 1 commit into
nasa:mainfrom
mrizvi96:206-harden-telemetry-ingestion-boundary

Conversation

@mrizvi96

Copy link
Copy Markdown

Fixes #206.

Changes

  • onair/data_handling/parser_util.py
    • floatify_input(): catches (ValueError, TypeError) around float()
      (no more TypeError crash on None/dict/list); non-finite results
      ("nan"/"inf" strings, NaN/Inf floats) never enter the output;
      unparseable values — including the "-" stale-data sentinel — are
      substituted with math.nan plus a print_msg WARNING naming the value
      (or dropped entirely when remove_str=True). The silent 0.0 fallback
      is removed everywhere; policy documented in the docstring.
    • convert_str_to_timestamp(): rejects non-str inputs up front;
      MM:SS fallback requires exactly two colon-separated parts, both
      integer-parseable, minute and second in 0..59 — else ValueError.
      "12:34:56" is no longer silently truncated; no IndexError /
      AttributeError leaks.
  • plugins/kalman/kalman_plugin.py — Plugin.update(): frames whose length
    does not match len(self.headers) are rejected with a WARNING naming both
    lengths; non-finite values are skipped per-attribute, so windows contain
    only finite floats (a skipped sample advances no window).
  • No public signatures changed; stdlib math only; no new dependencies.
  • Legacy tests updated ONLY where they encoded the removed 0.0-masking or
    mock-only behavior (every edit marked with an inline # updated: comment;
    no assertions weakened).

Validation

All 371 existing tests pass on the unchanged baseline (python -m pytest test/ -q); 401 pass with this change — 30 new tests:

  • 10 parser properties (never-raises on JSON-grade scalars, length
    preservation, finite-float identity, "-" sentinel policy, NaN/Inf
    normalization, timestamp validity), each at max_examples=1000, deadline=None;
  • 4 kalman property tests: a RuleBasedStateMachine feeding
    valid/junk/short/long/NaN-spiked frames (invariants: update() never
    raises, windows stay finite and length-aligned) plus 3 frame-rejection
    properties;
  • 16 example-based regression tests (8 per module) pinning exact epochs,
    exact warning text, and the frame-length guard.

Mutation testing (mutmut), before → after, two runner configurations
(legacy files only; legacy + property files derandomized), each run twice
with identical results:

Scope Before After
parser_util.py (52 mutants) 1 survivor in floatify_input 0 (hardened code: 71/71 killed)
Plugin.update() in-scope mutants 2 survivors 0

Full evidence — survivor catalogs, pre-patch falsifying examples, kill
tables, policy semantics, legacy-test change log — included in this PR
(doc/telemetry-hardening-report.md).

Notes for reviewers

  • Draft PR to solicit feedback, per contributing guidance for larger
    changes; happy to split into parser / kalman PRs if preferred.
  • The MM:SS epoch uses naive datetime.timestamp() (host-local time).
    This is pre-existing upstream behavior, intentionally preserved; flagged
    in the report (§11.3) as a candidate decision for maintainers.
  • Individual CLA per the contributing instructions: completed/submitted.

…ation, kalman frame guard) + property/kill tests

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

Labels

None yet

Projects

None yet

1 participant