Skip to content

Commit 5c10b37

Browse files
anandgupta42claude
andcommitted
test: add comprehensive E2E + adversarial tests for check command
- 58 new tests covering full handler flow with mocked `Dispatcher.call()` - E2E: all 7 check types, `--fail-on` exit codes, `--severity` filtering, `--policy` validation, unknown check names, schema resolution, batching, text/JSON output, mixed success/failure across checks - Adversarial: null bytes, shell metacharacters, 100K-char lines, Unicode/emoji, CRLF, spaces in filenames, deeply nested paths, malformed policy JSON, 1MB policy files, undefined/null finding fields, 5000 findings, XSS-like content, non-string severity, `__proto__` pollution, binary `.sql` content, symlinks, directory with `.sql` extension, duplicate file args, empty checks string - Fix: `normalizeSeverity()` now handles non-string inputs without crashing (previously threw on numeric/boolean/object severity from Dispatcher) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 55504fa commit 5c10b37

3 files changed

Lines changed: 995 additions & 22 deletions

File tree

packages/opencode/src/cli/cmd/check-helpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ export const VALID_CHECKS = new Set(["lint", "validate", "safety", "policy", "pi
4949
// Helpers
5050
// ---------------------------------------------------------------------------
5151

52-
export function normalizeSeverity(s?: string): Severity {
53-
if (!s) return "warning"
52+
export function normalizeSeverity(s?: string | unknown): Severity {
53+
if (!s || typeof s !== "string") return "warning"
5454
const lower = s.toLowerCase()
5555
if (lower === "error" || lower === "fatal" || lower === "critical") return "error"
5656
if (lower === "warning" || lower === "warn") return "warning"

0 commit comments

Comments
 (0)