nightytidy 0.3.7 → 0.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/nightytidy.js +1 -1
- package/package.json +1 -1
- package/src/agent/git-integration.js +4 -1
- package/src/claude.js +1 -1
- package/src/prompts/manifest.json +138 -138
- package/src/prompts/steps/02-test-coverage.md +181 -181
- package/src/prompts/steps/03-test-hardening.md +181 -181
- package/src/prompts/steps/04-test-architecture.md +130 -130
- package/src/prompts/steps/05-test-consolidation.md +165 -165
- package/src/prompts/steps/06-test-quality.md +211 -211
- package/src/prompts/steps/07-api-design.md +165 -165
- package/src/prompts/steps/08-security-sweep.md +207 -207
- package/src/prompts/steps/09-dependency-health.md +217 -217
- package/src/prompts/steps/10-codebase-cleanup.md +189 -189
- package/src/prompts/steps/11-crosscutting-concerns.md +196 -196
- package/src/prompts/steps/12-file-decomposition.md +263 -263
- package/src/prompts/steps/13-code-elegance.md +329 -329
- package/src/prompts/steps/14-architectural-complexity.md +297 -297
- package/src/prompts/steps/15-type-safety.md +192 -192
- package/src/prompts/steps/16-logging-error-message.md +173 -173
- package/src/prompts/steps/17-data-integrity.md +139 -139
- package/src/prompts/steps/18-performance.md +183 -183
- package/src/prompts/steps/19-cost-resource-optimization.md +136 -136
- package/src/prompts/steps/20-error-recovery.md +145 -145
- package/src/prompts/steps/21-race-condition-audit.md +178 -178
- package/src/prompts/steps/22-bug-hunt.md +229 -229
- package/src/prompts/steps/23-frontend-quality.md +210 -210
- package/src/prompts/steps/24-uiux-audit.md +284 -284
- package/src/prompts/steps/25-state-management.md +170 -170
- package/src/prompts/steps/26-perceived-performance.md +190 -190
- package/src/prompts/steps/27-devops.md +165 -165
- package/src/prompts/steps/28-scheduled-job-chron-jobs.md +141 -141
- package/src/prompts/steps/29-observability.md +152 -152
- package/src/prompts/steps/30-backup-check.md +155 -155
- package/src/prompts/steps/31-product-polish-ux-friction.md +122 -122
- package/src/prompts/steps/32-feature-discovery-opportunity.md +128 -128
- package/src/prompts/steps/33-strategic-opportunities.md +217 -217
|
@@ -1,211 +1,211 @@
|
|
|
1
|
-
# Test Quality & Adversarial Coverage Audit
|
|
2
|
-
|
|
3
|
-
You are running an overnight test quality and adversarial coverage audit. Unlike Test Coverage (which measures how many lines are touched) and Test Architecture (which evaluates structure and antipatterns), your job is narrower and more pointed: **do these tests verify behavior that actually matters, and would they catch what a real user — or a malicious one — would actually do?**
|
|
4
|
-
|
|
5
|
-
This is a READ-ONLY analysis. Do not create a branch or modify any code.
|
|
6
|
-
|
|
7
|
-
Ideally, run this after the Test Consolidation pass so you're analyzing a clean suite, not one padded with duplicates.
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## Global Rules
|
|
12
|
-
|
|
13
|
-
- Evaluate every test by asking: "If the production code silently returned the wrong answer here, would this test catch it?" If the answer is no, that's a finding.
|
|
14
|
-
- Be specific. "12 tests in `payment.test.ts` all verify the same happy-path charge with slightly different amounts — none test negative amounts, zero, or non-numeric input" is useful. "Tests lack edge case coverage" is not.
|
|
15
|
-
- A test that always passes regardless of whether the code is correct is worse than no test. Name these explicitly.
|
|
16
|
-
- Adversarial coverage is not about security theater — it's about testing the inputs real users send when confused, impatient, or malicious. These are the inputs that reveal the real behavior of the system.
|
|
17
|
-
- You have all night. Read every test file and its corresponding source module.
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## Phase 1: Assertion Quality Audit
|
|
22
|
-
|
|
23
|
-
Find tests that are executing code without meaningfully verifying anything.
|
|
24
|
-
|
|
25
|
-
### Category 1: Execution-only tests
|
|
26
|
-
Tests that run code but make no meaningful assertion about output, state, or side effects:
|
|
27
|
-
- `expect(() => fn()).not.toThrow()` as the only assertion — proves it didn't crash, nothing about correctness
|
|
28
|
-
- Calling a function and not asserting the return value
|
|
29
|
-
- Rendering a component and not asserting what rendered
|
|
30
|
-
- `expect(mock).toHaveBeenCalled()` on a mock that is unconditionally called in `beforeEach` (always passes regardless of production code behavior)
|
|
31
|
-
|
|
32
|
-
### Category 2: Tautological assertions
|
|
33
|
-
Assertions that are structurally guaranteed to pass:
|
|
34
|
-
- Asserting the shape of a mock's return value — you defined the mock, so it always returns what you told it to
|
|
35
|
-
- `expect(result).toBeDefined()` when the code path always returns a value
|
|
36
|
-
- `expect(arr.length).toBeGreaterThan(0)` on an array built from hardcoded test setup
|
|
37
|
-
- Asserting a boolean is `true` after calling a function that literally `return true`s unconditionally
|
|
38
|
-
|
|
39
|
-
### Category 3: Implementation-coupled assertions
|
|
40
|
-
Tests that claim to verify behavior but only verify implementation details:
|
|
41
|
-
- Asserting a specific internal method was called N times when what matters is the observable output
|
|
42
|
-
- Asserting the exact SQL query string instead of the query result
|
|
43
|
-
- Testing internal class state instead of observable behavior
|
|
44
|
-
- Asserting mock call order when order doesn't affect correctness
|
|
45
|
-
|
|
46
|
-
### Category 4: Assertion density
|
|
47
|
-
For each test file, calculate: total meaningful assertions / total tests. Files with a ratio below 1.5 are high-risk. Report the 10 worst offenders with specifics.
|
|
48
|
-
|
|
49
|
-
---
|
|
50
|
-
|
|
51
|
-
## Phase 2: Test Intent vs. Test Name Audit
|
|
52
|
-
|
|
53
|
-
Find tests where the name promises one thing and the assertions verify something different — or nothing at all.
|
|
54
|
-
|
|
55
|
-
Scan for:
|
|
56
|
-
- Test name says "validates email" but assertions only check the function doesn't throw
|
|
57
|
-
- Test name says "returns 404 when user not found" but the mock always returns a user
|
|
58
|
-
- Test name says "handles concurrent requests" but the test is entirely synchronous
|
|
59
|
-
- `describe` block label is no longer accurate because the underlying code changed
|
|
60
|
-
- Test describes a specific scenario but setup creates a different one
|
|
61
|
-
|
|
62
|
-
These are the most confidence-eroding tests in a suite. They pass in CI and make the team believe something is covered that isn't.
|
|
63
|
-
|
|
64
|
-
---
|
|
65
|
-
|
|
66
|
-
## Phase 3: Boundary & Edge Case Coverage
|
|
67
|
-
|
|
68
|
-
For every module with test coverage, evaluate whether tests cover what actually happens at the edges — not just the comfortable middle.
|
|
69
|
-
|
|
70
|
-
For each function and endpoint, check whether the following are covered. Report the gaps.
|
|
71
|
-
|
|
72
|
-
**Numeric boundaries:** zero, negative numbers, max integer, floating point imprecision (e.g., `0.1 + 0.2`), NaN, Infinity
|
|
73
|
-
|
|
74
|
-
**String boundaries:** empty string, single character, maximum allowed length, over-maximum length, whitespace-only
|
|
75
|
-
|
|
76
|
-
**Collection boundaries:** empty array/object, single element, maximum count, duplicate elements, null inside collection
|
|
77
|
-
|
|
78
|
-
**Boolean/falsy ambiguity:** `null` vs `false` vs `undefined` vs `0` vs `""` — all falsy, not interchangeable. Tests that only cover `null` when code paths also handle `undefined` differently are gaps.
|
|
79
|
-
|
|
80
|
-
**Date and time edges:** midnight, end of month, leap day (Feb 29), DST transition, epoch (0), far future, far past
|
|
81
|
-
|
|
82
|
-
**Reference edges:** non-existent ID, deleted-entity ID, ID belonging to a different user, ID of wrong entity type
|
|
83
|
-
|
|
84
|
-
For each module, rate boundary coverage: **Thorough** / **Partial** / **Happy-path only** / **None**
|
|
85
|
-
|
|
86
|
-
---
|
|
87
|
-
|
|
88
|
-
## Phase 4: Adversarial Input Coverage
|
|
89
|
-
|
|
90
|
-
This is the gap most test suites leave entirely open. Real users — and attackers — don't send well-formed inputs. Check whether any test in the suite covers the following categories for each API endpoint, form handler, data import function, or external input boundary.
|
|
91
|
-
|
|
92
|
-
### Malformed structure
|
|
93
|
-
- Completely wrong type: string where integer expected, array where object expected, object where array expected, number where boolean expected
|
|
94
|
-
- Missing required fields
|
|
95
|
-
- Extra unexpected fields
|
|
96
|
-
- Deeply nested structures beyond expected depth
|
|
97
|
-
- Extremely large payloads
|
|
98
|
-
|
|
99
|
-
### Injection and encoding
|
|
100
|
-
- SQL injection strings in any text field: `' OR '1'='1`, `'; DROP TABLE users; --`
|
|
101
|
-
- Script tags in user-supplied text: `<script>alert(1)</script>`
|
|
102
|
-
- Path traversal sequences: `../../../etc/passwd`, `..%2F..%2F`
|
|
103
|
-
- Null bytes: `hello\0world`
|
|
104
|
-
- Unicode edge cases: right-to-left override characters, zero-width spaces, lookalike characters, emoji in identifier fields
|
|
105
|
-
|
|
106
|
-
### Numeric attacks
|
|
107
|
-
- Negative prices or quantities
|
|
108
|
-
- Zero as an amount where zero is semantically invalid (zero-dollar charges, zero-item orders)
|
|
109
|
-
- Floating point that doesn't round evenly: `$0.001`, `33.333...`
|
|
110
|
-
- Integer overflow values
|
|
111
|
-
- Scientific notation where plain integers are expected
|
|
112
|
-
|
|
113
|
-
### Auth and permission boundary inputs
|
|
114
|
-
- Valid session token belonging to a different user, used against another user's resource (IDOR test)
|
|
115
|
-
- Expired token
|
|
116
|
-
- Malformed token (truncated, wrong signature, wrong algorithm)
|
|
117
|
-
- Token with claims removed or altered
|
|
118
|
-
- Request with no auth where auth is required
|
|
119
|
-
- Request with auth for a lower-permission role on a higher-permission endpoint
|
|
120
|
-
|
|
121
|
-
For each input boundary in the codebase, report: **Covered** / **Partially covered** / **Not covered**, and the specific missing categories.
|
|
122
|
-
|
|
123
|
-
---
|
|
124
|
-
|
|
125
|
-
## Phase 5: State-Dependent & Concurrency Gaps
|
|
126
|
-
|
|
127
|
-
Real users encounter states that tests rarely simulate. For every stateful entity or multi-step flow in the codebase:
|
|
128
|
-
|
|
129
|
-
**Idempotency:** What happens if the same action is submitted twice? (double form submission, duplicate API call, retry after timeout) Is there a test for it?
|
|
130
|
-
|
|
131
|
-
**Out-of-order operations:** What happens if step 2 is performed before step 1? If a resource is accessed after deletion? If a user acts on a resource that was modified by another user since they loaded it?
|
|
132
|
-
|
|
133
|
-
**Permission revocation mid-session:** User loads a page with permission, permission is revoked, user submits — what happens?
|
|
134
|
-
|
|
135
|
-
**Partial failure state:** Multi-step operation (create + notify + log) — if step 2 fails, what state is the system in? Is there a test that simulates that failure?
|
|
136
|
-
|
|
137
|
-
For each stateful entity, report: states tested vs. states that exist, untested transitions, and the worst-case consequence of an untested path.
|
|
138
|
-
|
|
139
|
-
---
|
|
140
|
-
|
|
141
|
-
## Phase 6: Error Path Coverage Ratio
|
|
142
|
-
|
|
143
|
-
Most tests cover happy paths. Find the gap for each critical module.
|
|
144
|
-
|
|
145
|
-
For each module with significant test coverage, estimate:
|
|
146
|
-
- Total error-producing code paths (catch blocks, null returns, 4xx responses, validation failures, thrown exceptions)
|
|
147
|
-
- How many of those have a corresponding test that actually triggers them
|
|
148
|
-
|
|
149
|
-
Report the ratio and the worst uncovered error paths — specifically the ones where being wrong means data corruption, silent failure, or incorrect behavior visible to users.
|
|
150
|
-
|
|
151
|
-
---
|
|
152
|
-
|
|
153
|
-
## Output
|
|
154
|
-
|
|
155
|
-
Create `audit-reports/` in project root if needed. Save as `audit-reports/06_TEST_QUALITY_REPORT_[run-number]_[date]_[time in user's local time].md`, incrementing run number based on existing reports.
|
|
156
|
-
|
|
157
|
-
### Report Structure
|
|
158
|
-
|
|
159
|
-
1. **Executive Summary** — Overall quality rating (illusory / weak / adequate / strong / excellent), assertion quality score, adversarial coverage score, one-line verdict: "This suite [would / would not] catch a realistic injection attempt or a subtle off-by-one in billing logic."
|
|
160
|
-
|
|
161
|
-
2. **Assertion Quality Findings** — Tables per category (execution-only, tautological, implementation-coupled), assertion density table (10 worst offenders with file, ratio, and worst examples).
|
|
162
|
-
|
|
163
|
-
3. **Test Intent vs. Name Mismatches** — Full list: | File | Test Name | Claims to Test | Actually Tests | Risk |
|
|
164
|
-
|
|
165
|
-
4. **Boundary Coverage** — Per-module rating table: | Module | Numeric | String | Collection | Date/Time | Reference | Overall |. Worst gaps with specific missing cases.
|
|
166
|
-
|
|
167
|
-
5. **Adversarial Input Coverage** — Per input boundary: | Endpoint/Function | Malformed Structure | Injection/Encoding | Numeric Attacks | Auth Boundary | Overall |. Every "Not covered" entry on an auth or data-mutation endpoint is HIGH severity.
|
|
168
|
-
|
|
169
|
-
6. **State-Dependent & Concurrency Gaps** — Per entity: | Entity | States Tested | States Untested | Idempotency Tested? | Worst Untested Scenario |
|
|
170
|
-
|
|
171
|
-
7. **Error Path Coverage** — Per module: | Module | Error Paths | Tested | Untested | Consequence of Worst Uncovered |
|
|
172
|
-
|
|
173
|
-
8. **Priority Remediation List** — Ordered by risk: which gaps to close first, what specific tests to write, estimated effort per item.
|
|
174
|
-
|
|
175
|
-
---
|
|
176
|
-
|
|
177
|
-
## Chat Output Requirement
|
|
178
|
-
|
|
179
|
-
In addition to writing the full report file, you MUST print a summary directly in the conversation when you finish.
|
|
180
|
-
|
|
181
|
-
### 1. Status Line
|
|
182
|
-
One sentence: what you analyzed and how long it took. (No code was changed — no test status to report.)
|
|
183
|
-
|
|
184
|
-
### 2. Key Findings
|
|
185
|
-
The most important gaps discovered — specific and actionable, not vague. Lead with impact.
|
|
186
|
-
|
|
187
|
-
**Good:** "HIGH: Zero adversarial input tests exist on any auth or payment endpoint — no test covers a negative price, a stolen session token, or SQL injection in any user-supplied field."
|
|
188
|
-
**Bad:** "Found some test quality issues."
|
|
189
|
-
|
|
190
|
-
### 3. Changes Made
|
|
191
|
-
This is a read-only run — skip this section.
|
|
192
|
-
|
|
193
|
-
### 4. Recommendations
|
|
194
|
-
|
|
195
|
-
If there are legitimately beneficial recommendations worth pursuing right now, present them in a table. Do **not** force recommendations — if the audit surfaced no actionable improvements, simply state that no recommendations are warranted at this time and move on.
|
|
196
|
-
|
|
197
|
-
| # | Recommendation | Impact | Risk if Ignored | Worth Doing? | Details |
|
|
198
|
-
|---|---|---|---|---|---|
|
|
199
|
-
| *Sequential number* | *Short description (≤10 words)* | *What improves if addressed* | *Low / Medium / High / Critical* | *Yes / Probably / Only if time allows* | *1–3 sentences explaining the reasoning, context, or implementation guidance* |
|
|
200
|
-
|
|
201
|
-
Order rows by risk descending. Be honest in "Worth Doing?" — not everything flagged is worth the engineering time.
|
|
202
|
-
|
|
203
|
-
### 5. Report Location
|
|
204
|
-
State the full path to the detailed report file for deeper review.
|
|
205
|
-
|
|
206
|
-
---
|
|
207
|
-
|
|
208
|
-
**Formatting rules for chat output:**
|
|
209
|
-
- Use markdown headers, bold for severity labels, and bullet points for scannability.
|
|
210
|
-
- Do not duplicate the full report contents — just the highlights and recommendations.
|
|
211
|
-
- If you made zero findings in a phase, say so in one line rather than omitting it silently.
|
|
1
|
+
# Test Quality & Adversarial Coverage Audit
|
|
2
|
+
|
|
3
|
+
You are running an overnight test quality and adversarial coverage audit. Unlike Test Coverage (which measures how many lines are touched) and Test Architecture (which evaluates structure and antipatterns), your job is narrower and more pointed: **do these tests verify behavior that actually matters, and would they catch what a real user — or a malicious one — would actually do?**
|
|
4
|
+
|
|
5
|
+
This is a READ-ONLY analysis. Do not create a branch or modify any code.
|
|
6
|
+
|
|
7
|
+
Ideally, run this after the Test Consolidation pass so you're analyzing a clean suite, not one padded with duplicates.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Global Rules
|
|
12
|
+
|
|
13
|
+
- Evaluate every test by asking: "If the production code silently returned the wrong answer here, would this test catch it?" If the answer is no, that's a finding.
|
|
14
|
+
- Be specific. "12 tests in `payment.test.ts` all verify the same happy-path charge with slightly different amounts — none test negative amounts, zero, or non-numeric input" is useful. "Tests lack edge case coverage" is not.
|
|
15
|
+
- A test that always passes regardless of whether the code is correct is worse than no test. Name these explicitly.
|
|
16
|
+
- Adversarial coverage is not about security theater — it's about testing the inputs real users send when confused, impatient, or malicious. These are the inputs that reveal the real behavior of the system.
|
|
17
|
+
- You have all night. Read every test file and its corresponding source module.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Phase 1: Assertion Quality Audit
|
|
22
|
+
|
|
23
|
+
Find tests that are executing code without meaningfully verifying anything.
|
|
24
|
+
|
|
25
|
+
### Category 1: Execution-only tests
|
|
26
|
+
Tests that run code but make no meaningful assertion about output, state, or side effects:
|
|
27
|
+
- `expect(() => fn()).not.toThrow()` as the only assertion — proves it didn't crash, nothing about correctness
|
|
28
|
+
- Calling a function and not asserting the return value
|
|
29
|
+
- Rendering a component and not asserting what rendered
|
|
30
|
+
- `expect(mock).toHaveBeenCalled()` on a mock that is unconditionally called in `beforeEach` (always passes regardless of production code behavior)
|
|
31
|
+
|
|
32
|
+
### Category 2: Tautological assertions
|
|
33
|
+
Assertions that are structurally guaranteed to pass:
|
|
34
|
+
- Asserting the shape of a mock's return value — you defined the mock, so it always returns what you told it to
|
|
35
|
+
- `expect(result).toBeDefined()` when the code path always returns a value
|
|
36
|
+
- `expect(arr.length).toBeGreaterThan(0)` on an array built from hardcoded test setup
|
|
37
|
+
- Asserting a boolean is `true` after calling a function that literally `return true`s unconditionally
|
|
38
|
+
|
|
39
|
+
### Category 3: Implementation-coupled assertions
|
|
40
|
+
Tests that claim to verify behavior but only verify implementation details:
|
|
41
|
+
- Asserting a specific internal method was called N times when what matters is the observable output
|
|
42
|
+
- Asserting the exact SQL query string instead of the query result
|
|
43
|
+
- Testing internal class state instead of observable behavior
|
|
44
|
+
- Asserting mock call order when order doesn't affect correctness
|
|
45
|
+
|
|
46
|
+
### Category 4: Assertion density
|
|
47
|
+
For each test file, calculate: total meaningful assertions / total tests. Files with a ratio below 1.5 are high-risk. Report the 10 worst offenders with specifics.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Phase 2: Test Intent vs. Test Name Audit
|
|
52
|
+
|
|
53
|
+
Find tests where the name promises one thing and the assertions verify something different — or nothing at all.
|
|
54
|
+
|
|
55
|
+
Scan for:
|
|
56
|
+
- Test name says "validates email" but assertions only check the function doesn't throw
|
|
57
|
+
- Test name says "returns 404 when user not found" but the mock always returns a user
|
|
58
|
+
- Test name says "handles concurrent requests" but the test is entirely synchronous
|
|
59
|
+
- `describe` block label is no longer accurate because the underlying code changed
|
|
60
|
+
- Test describes a specific scenario but setup creates a different one
|
|
61
|
+
|
|
62
|
+
These are the most confidence-eroding tests in a suite. They pass in CI and make the team believe something is covered that isn't.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Phase 3: Boundary & Edge Case Coverage
|
|
67
|
+
|
|
68
|
+
For every module with test coverage, evaluate whether tests cover what actually happens at the edges — not just the comfortable middle.
|
|
69
|
+
|
|
70
|
+
For each function and endpoint, check whether the following are covered. Report the gaps.
|
|
71
|
+
|
|
72
|
+
**Numeric boundaries:** zero, negative numbers, max integer, floating point imprecision (e.g., `0.1 + 0.2`), NaN, Infinity
|
|
73
|
+
|
|
74
|
+
**String boundaries:** empty string, single character, maximum allowed length, over-maximum length, whitespace-only
|
|
75
|
+
|
|
76
|
+
**Collection boundaries:** empty array/object, single element, maximum count, duplicate elements, null inside collection
|
|
77
|
+
|
|
78
|
+
**Boolean/falsy ambiguity:** `null` vs `false` vs `undefined` vs `0` vs `""` — all falsy, not interchangeable. Tests that only cover `null` when code paths also handle `undefined` differently are gaps.
|
|
79
|
+
|
|
80
|
+
**Date and time edges:** midnight, end of month, leap day (Feb 29), DST transition, epoch (0), far future, far past
|
|
81
|
+
|
|
82
|
+
**Reference edges:** non-existent ID, deleted-entity ID, ID belonging to a different user, ID of wrong entity type
|
|
83
|
+
|
|
84
|
+
For each module, rate boundary coverage: **Thorough** / **Partial** / **Happy-path only** / **None**
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Phase 4: Adversarial Input Coverage
|
|
89
|
+
|
|
90
|
+
This is the gap most test suites leave entirely open. Real users — and attackers — don't send well-formed inputs. Check whether any test in the suite covers the following categories for each API endpoint, form handler, data import function, or external input boundary.
|
|
91
|
+
|
|
92
|
+
### Malformed structure
|
|
93
|
+
- Completely wrong type: string where integer expected, array where object expected, object where array expected, number where boolean expected
|
|
94
|
+
- Missing required fields
|
|
95
|
+
- Extra unexpected fields
|
|
96
|
+
- Deeply nested structures beyond expected depth
|
|
97
|
+
- Extremely large payloads
|
|
98
|
+
|
|
99
|
+
### Injection and encoding
|
|
100
|
+
- SQL injection strings in any text field: `' OR '1'='1`, `'; DROP TABLE users; --`
|
|
101
|
+
- Script tags in user-supplied text: `<script>alert(1)</script>`
|
|
102
|
+
- Path traversal sequences: `../../../etc/passwd`, `..%2F..%2F`
|
|
103
|
+
- Null bytes: `hello\0world`
|
|
104
|
+
- Unicode edge cases: right-to-left override characters, zero-width spaces, lookalike characters, emoji in identifier fields
|
|
105
|
+
|
|
106
|
+
### Numeric attacks
|
|
107
|
+
- Negative prices or quantities
|
|
108
|
+
- Zero as an amount where zero is semantically invalid (zero-dollar charges, zero-item orders)
|
|
109
|
+
- Floating point that doesn't round evenly: `$0.001`, `33.333...`
|
|
110
|
+
- Integer overflow values
|
|
111
|
+
- Scientific notation where plain integers are expected
|
|
112
|
+
|
|
113
|
+
### Auth and permission boundary inputs
|
|
114
|
+
- Valid session token belonging to a different user, used against another user's resource (IDOR test)
|
|
115
|
+
- Expired token
|
|
116
|
+
- Malformed token (truncated, wrong signature, wrong algorithm)
|
|
117
|
+
- Token with claims removed or altered
|
|
118
|
+
- Request with no auth where auth is required
|
|
119
|
+
- Request with auth for a lower-permission role on a higher-permission endpoint
|
|
120
|
+
|
|
121
|
+
For each input boundary in the codebase, report: **Covered** / **Partially covered** / **Not covered**, and the specific missing categories.
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Phase 5: State-Dependent & Concurrency Gaps
|
|
126
|
+
|
|
127
|
+
Real users encounter states that tests rarely simulate. For every stateful entity or multi-step flow in the codebase:
|
|
128
|
+
|
|
129
|
+
**Idempotency:** What happens if the same action is submitted twice? (double form submission, duplicate API call, retry after timeout) Is there a test for it?
|
|
130
|
+
|
|
131
|
+
**Out-of-order operations:** What happens if step 2 is performed before step 1? If a resource is accessed after deletion? If a user acts on a resource that was modified by another user since they loaded it?
|
|
132
|
+
|
|
133
|
+
**Permission revocation mid-session:** User loads a page with permission, permission is revoked, user submits — what happens?
|
|
134
|
+
|
|
135
|
+
**Partial failure state:** Multi-step operation (create + notify + log) — if step 2 fails, what state is the system in? Is there a test that simulates that failure?
|
|
136
|
+
|
|
137
|
+
For each stateful entity, report: states tested vs. states that exist, untested transitions, and the worst-case consequence of an untested path.
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Phase 6: Error Path Coverage Ratio
|
|
142
|
+
|
|
143
|
+
Most tests cover happy paths. Find the gap for each critical module.
|
|
144
|
+
|
|
145
|
+
For each module with significant test coverage, estimate:
|
|
146
|
+
- Total error-producing code paths (catch blocks, null returns, 4xx responses, validation failures, thrown exceptions)
|
|
147
|
+
- How many of those have a corresponding test that actually triggers them
|
|
148
|
+
|
|
149
|
+
Report the ratio and the worst uncovered error paths — specifically the ones where being wrong means data corruption, silent failure, or incorrect behavior visible to users.
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Output
|
|
154
|
+
|
|
155
|
+
Create `audit-reports/` in project root if needed. Save as `audit-reports/06_TEST_QUALITY_REPORT_[run-number]_[date]_[time in user's local time].md`, incrementing run number based on existing reports.
|
|
156
|
+
|
|
157
|
+
### Report Structure
|
|
158
|
+
|
|
159
|
+
1. **Executive Summary** — Overall quality rating (illusory / weak / adequate / strong / excellent), assertion quality score, adversarial coverage score, one-line verdict: "This suite [would / would not] catch a realistic injection attempt or a subtle off-by-one in billing logic."
|
|
160
|
+
|
|
161
|
+
2. **Assertion Quality Findings** — Tables per category (execution-only, tautological, implementation-coupled), assertion density table (10 worst offenders with file, ratio, and worst examples).
|
|
162
|
+
|
|
163
|
+
3. **Test Intent vs. Name Mismatches** — Full list: | File | Test Name | Claims to Test | Actually Tests | Risk |
|
|
164
|
+
|
|
165
|
+
4. **Boundary Coverage** — Per-module rating table: | Module | Numeric | String | Collection | Date/Time | Reference | Overall |. Worst gaps with specific missing cases.
|
|
166
|
+
|
|
167
|
+
5. **Adversarial Input Coverage** — Per input boundary: | Endpoint/Function | Malformed Structure | Injection/Encoding | Numeric Attacks | Auth Boundary | Overall |. Every "Not covered" entry on an auth or data-mutation endpoint is HIGH severity.
|
|
168
|
+
|
|
169
|
+
6. **State-Dependent & Concurrency Gaps** — Per entity: | Entity | States Tested | States Untested | Idempotency Tested? | Worst Untested Scenario |
|
|
170
|
+
|
|
171
|
+
7. **Error Path Coverage** — Per module: | Module | Error Paths | Tested | Untested | Consequence of Worst Uncovered |
|
|
172
|
+
|
|
173
|
+
8. **Priority Remediation List** — Ordered by risk: which gaps to close first, what specific tests to write, estimated effort per item.
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## Chat Output Requirement
|
|
178
|
+
|
|
179
|
+
In addition to writing the full report file, you MUST print a summary directly in the conversation when you finish.
|
|
180
|
+
|
|
181
|
+
### 1. Status Line
|
|
182
|
+
One sentence: what you analyzed and how long it took. (No code was changed — no test status to report.)
|
|
183
|
+
|
|
184
|
+
### 2. Key Findings
|
|
185
|
+
The most important gaps discovered — specific and actionable, not vague. Lead with impact.
|
|
186
|
+
|
|
187
|
+
**Good:** "HIGH: Zero adversarial input tests exist on any auth or payment endpoint — no test covers a negative price, a stolen session token, or SQL injection in any user-supplied field."
|
|
188
|
+
**Bad:** "Found some test quality issues."
|
|
189
|
+
|
|
190
|
+
### 3. Changes Made
|
|
191
|
+
This is a read-only run — skip this section.
|
|
192
|
+
|
|
193
|
+
### 4. Recommendations
|
|
194
|
+
|
|
195
|
+
If there are legitimately beneficial recommendations worth pursuing right now, present them in a table. Do **not** force recommendations — if the audit surfaced no actionable improvements, simply state that no recommendations are warranted at this time and move on.
|
|
196
|
+
|
|
197
|
+
| # | Recommendation | Impact | Risk if Ignored | Worth Doing? | Details |
|
|
198
|
+
|---|---|---|---|---|---|
|
|
199
|
+
| *Sequential number* | *Short description (≤10 words)* | *What improves if addressed* | *Low / Medium / High / Critical* | *Yes / Probably / Only if time allows* | *1–3 sentences explaining the reasoning, context, or implementation guidance* |
|
|
200
|
+
|
|
201
|
+
Order rows by risk descending. Be honest in "Worth Doing?" — not everything flagged is worth the engineering time.
|
|
202
|
+
|
|
203
|
+
### 5. Report Location
|
|
204
|
+
State the full path to the detailed report file for deeper review.
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
**Formatting rules for chat output:**
|
|
209
|
+
- Use markdown headers, bold for severity labels, and bullet points for scannability.
|
|
210
|
+
- Do not duplicate the full report contents — just the highlights and recommendations.
|
|
211
|
+
- If you made zero findings in a phase, say so in one line rather than omitting it silently.
|