Commit db3c48b
authored
test: add Hypothesis fuzz coverage and macos-latest CI matrix (#75)
* test: add Hypothesis fuzz coverage and macos-latest CI matrix
Add tests/test_parser_fuzz.py with strategies for malformed/truncated JSONL, unknown record types, missing/extra fields, deep nesting, long lines, empty lines, and null bytes. Harden parse_session against adversarial inputs found by fuzz (non-dict JSON values, unhashable type keys, non-str metadata fields). Extend CI matrix to macos-latest for pytest, integration-tests, js-tests, and lint-and-audit. Document Ubuntu + Windows + macOS CI in CONTRIBUTING.
* fix: macOS js-tests rollup install and fuzz tmp_path cleanup
Install platform Rollup binary after npm ci; drop Linux-only optionalDep.
Use pytest tmp_path in test_parser_fuzz.py instead of leaking mkdtemp dirs.
* fix(test): guard dict() cast in structured_entry to fix mypy arg-type error
* fix(parser,test): harden token arithmetic and wire fuzz CI profile
Add _safe_int() so non-numeric usage fields coerce to 0 instead of raising
TypeError during token accumulation; apply to all token fields. Drop
max_examples/deadline from the test decorator so the conftest ci/dev profile
actually governs fuzz runtime. Inline _fuzz_jsonl_path, tighten truncation
model and unknown-type assertion, simplify ALLOWED_EXCEPTIONS, and note macOS
in the CONTRIBUTING PR checklist.
* fix(parser): coerce non-finite usage tokens and tidy review nits
Guard _safe_int against NaN/Infinity (json.loads accepts these literals;
int(nan)/int(inf) raise), broaden fuzz floats to cover them, and add an
explicit non-finite regression test. Revert entry_counts to truthiness so
empty-string types stay skipped, wrap service_tier in the message payload,
and drop the no-op [tool.hypothesis] block from pyproject.toml.
* fix(parser): clamp _safe_int to non-negative for token accounting
Negative usage token values from adversarial JSONL must not reduce session
metadata totals; apply max(0, ...) in _safe_int and add regression test.1 parent 8083f3e commit db3c48b
8 files changed
Lines changed: 385 additions & 39 deletions
File tree
- .github/workflows
- tests
- utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
| 86 | + | |
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | | - | |
| 141 | + | |
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| |||
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
177 | | - | |
| 177 | + | |
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
191 | 206 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
| 115 | + | |
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | 15 | | |
19 | 16 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| 11 | + | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
13 | 21 | | |
14 | 22 | | |
15 | 23 | | |
| |||
0 commit comments