Repository navigation
Commit 913097a
authored
fix(test): size TestDetectionScansUntruncatedResponse for the race detector (#1207)
The test added in #1174 failed in both Unit Tests and End-to-End Tests, and the
defect is its payload sizing rather than anything it guards.
To place a secret past the storage cut it padded the response to
storage.DefaultMaxResponseSize+10_000 (~75KB), relying on the 64KB default cap.
security.Detector.Scan costs ~5.5us/byte, and the race detector multiplies that
by ~24x (measured: 114-137us/byte at 1K-75K). So the scan took ~9.5s against the
5s poll deadline in waitForDetectionMetadata. Because runAsyncDetection only
writes metadata on a hit, an over-budget scan surfaces as "timed out waiting for
detection metadata" rather than a failed assertion, which is why it read as a
logic failure. CI runs -race in both workflows; a plain local run does not.
Set the cap explicitly with SetMaxResponseSize(1024) and pad to 4KB instead. The
seam is identical - the AWS key sits at bytes [4113, 4133), 3089 bytes past the
1024-byte cut - and truncateResponse honours any positive maxSize with no
minimum floor. Runtime drops from ~9.5s to ~0.5s per subtest.
Verified:
- 5/5 runs under -race, 0.45-0.50s per subtest against the 5s deadline
- negative control: moving the detectionSource capture back to after
truncateForStorage in both handlers still fails the test at the smaller
payload, so it is not passing vacuously
- second control: stubbing truncateForStorage to a no-op fails the
NotContains assertion, proving the key is genuinely past the cut
- whole internal/runtime package green under -race, under the unit-tests.yml
invocation and under the e2e-tests.yml -short invocation
- headroom measured under CPU oversubscription: still passes at 8x slowdown
(2.96-3.76s), breaks only around 10.8x
TestDefaultResponseCapAppliesWithoutConfig continues to cover the 64KB default
separately, so no coverage is lost.1 parent 7a27851 commit 913097a
1 file changed
Lines changed: 12 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
256 | 263 | | |
257 | 264 | | |
258 | | - | |
259 | | - | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
260 | 268 | | |
261 | 269 | | |
262 | 270 | | |
263 | 271 | | |
264 | 272 | | |
265 | 273 | | |
| 274 | + | |
266 | 275 | | |
267 | 276 | | |
268 | 277 | | |
| |||
291 | 300 | | |
292 | 301 | | |
293 | 302 | | |
| 303 | + | |
294 | 304 | | |
295 | 305 | | |
296 | 306 | | |
| |||
0 commit comments