gstack-game icon indicating copy to clipboard operation
gstack-game copied to clipboard

test: security regression tests for telemetry and review-log

Open fagemx opened this issue 8 months ago • 0 comments

Problem

gstack-game's #23 added security hardening (json_safe, JSON.parse gate, random UUID, duration validation) but with zero regression tests. If someone accidentally removes the sanitization, nothing catches it.

gstack upstream has 20 security regression tests across 7 test files (PR #595, v0.13.1.0) plus 6 audit compliance tests (PR #574).

What to do

Add regression tests to `test/` that verify:

telemetry-log tests

  1. `json_safe()` strips quotes from input
  2. `json_safe()` strips backslashes
  3. `json_safe()` strips control characters (\n, \r, \t)
  4. `json_safe()` caps output at 200 chars
  5. Duration rejects negative values
  6. Duration caps at 86400
  7. Installation ID file is created on first run
  8. Installation ID is reused on subsequent runs

review-log tests

  1. Valid JSON is accepted
  2. Malformed JSON is rejected with non-zero exit
  3. JSON with injection payload is rejected

preamble tests

  1. Telemetry line uses `_SLUG_SAFE` not `_SLUG`
  2. Telemetry line uses `_BRANCH_SAFE` not `_BRANCH`

Implementation

Create `test/security.test.ts` with bash-level tests:

  • Use `execSync` to invoke bin/ scripts with test inputs
  • Use temp directories for state isolation
  • Verify JSONL output is valid JSON

Upstream Reference

  • gstack PR #595: 20 tests in `test/telemetry.test.ts`, `browse/test/adversarial-security.test.ts`, etc.
  • gstack PR #574: 6 tests in `test/audit-compliance.test.ts`

Effort: MEDIUM

New test file, ~150 lines. No production code changes.

fagemx avatar Mar 29 '26 05:03 fagemx