13
0
Fork 0
mirror of https://github.com/yannh/kubeconform.git synced 2026-07-04 02:19:31 +00:00
Commit graph

7 commits

Author SHA1 Message Date
Nikolai Emil Damm
d3ae574bf2
fix: copy scanner bytes in FromStream to prevent aliasing data race
FromStream set each Resource's Bytes to scanner.Bytes(), which aliases
the bufio.Scanner's internal buffer. Resources are emitted on a channel
and retained/parsed by the consumer concurrently with the producer
goroutine; when the scanner refills its buffer for later documents it
overwrites the slices earlier Resources still point at. Consumers that
parse resources as they arrive (e.g. ValidateWithContext) then read
corrupted bytes — a later document spliced into the one being parsed —
surfacing as non-deterministic YAML parse errors on large multi-document
streams (a different resource fails on each run).

Clone the scanner bytes so each Resource owns its slice. Adds a
regression test that streams >4MB (forcing the scanner to refill) and
asserts every resource's bytes are intact after draining.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-25 02:50:27 +02:00
Christoph Mertz
65968cf540 remove gosimple offences 2021-02-19 17:01:54 +01:00
Yann Hamon
300b571c33 linting / refactor 2020-11-15 12:12:37 +01:00
Yann Hamon
3a2d4705f5 better yaml splitting - not perfect but similar to k8s - fix path logging 2020-11-08 23:48:02 +01:00
Yann Hamon
358f145023 Add support for -exit-on-error 2020-11-08 10:08:14 +01:00
Yann Hamon
0152d8c209 add tests for command line parsing 2020-11-01 23:18:39 +01:00
Yann Hamon
51e5f38430 Add unit tests for reading resources from an io.Reader 2020-11-01 22:41:18 +01:00