Skip to content

[SEC-08] assert used for input/state validation (stripped under python -O) (Medium) #243

@kgdunn

Description

@kgdunn

From SECURITY_AUDIT.md (SEC-08). Severity: Untrusted = Medium, Local-trusted = Low.

Issue

Public-facing argument/shape validation done via assert is removed when Python runs with -O, silently disabling the checks and allowing invalid input to corrupt results or crash later in an obscure place. ~105 instances; validation-style examples:

  • process_improve/regression/methods.py:486-489,615
  • process_improve/experiments/optimal.py:79-80
  • process_improve/batch/data_input.py:67,74,81,86,104,146,152
  • process_improve/monitoring/control_charts.py:104-105,181-186
  • process_improve/univariate/metrics.py:397,583,733-734

Fix direction

Convert validation asserts (those checking user-supplied arguments or external data) to explicit if not ...: raise ValueError/TypeError(...). Genuine internal invariants may remain asserts but prefer explicit raises at API boundaries.

Tests

  • Invalid input raises the expected exception even under -O (or simply assert the explicit raise).

Note

Large and somewhat mechanical; may be split per-module if a single PR gets unwieldy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions