mirror of
https://github.com/morluto/rea.git
synced 2026-11-29 01:46:39 +00:00
* feat(artifacts): inventory Kubernetes audit logs offline A Kubernetes audit log exported from kube-apiserver is JSON-lines that the inventory treated as an unknown file: no format claim, no reader, and no way to see what an acquired log declares without a live cluster. Recognize the format from its first event and report, offline, the line, stage and verb totals and a bounded window of the events joined on their auditID. Each line stays an event in its own right, so a request whose stages were written out of order, repeated at one stage, or missing a stage is reported rather than reordered into a tidy request. Unknown API versions keep their auditID and stage but are not interpreted under field names the version may not use. Malformed lines are counted and bounded, never dropped silently. Refs #11352 (first slice: request, user, object reference and response code; request/response bodies, annotations and impersonation metadata are not read). * fix(artifacts): bound Kubernetes audit inventory and preserve stage evidence * fix(artifacts): preserve audit fields and extend first-record recognition * fix(artifacts): stream audit identity without decoding skipped bodies * fix(artifacts): handle every audit probe tokenizer event * fix(artifacts): read padded Kubernetes audit logs and modelled stages Recognition stopped at the first newline and rejected a leading UTF-8 BOM, while the reader skipped blank lines and trimmed that BOM away. Both now treat empty lines, JSON whitespace, and one leading U+FEFF as padding. Request fields come from the first stage whose API version is modelled, so an earlier unmodelled stage no longer hides a later v1 record. * fix(artifacts): skip unowned Kubernetes audit JSON bodies JSON.parse built a value tree for ignored request and response objects, so a deeply nested body could abort the process. Each line is tokenized and only the summary fields are kept. The tokenizer stops at 64 containers; identity already read is kept, and a deeper body before that identity is one line diagnostic. * fix(artifacts): report audit depth limits and wrong field shapes A container where a scalar or string list was required now leaves that field null, and a source address or group list past the retained text budget is not stored. Lines that exceed the tokenizer depth are counted separately from malformed JSON, and a sampled request says when the scan stopped early. Recognition uses the same depth cap and does not flush a tokenizer that already stopped. * fix(artifacts): keep audit field omission and last-key facts A source address or group list past the retained text budget sets request_fields_omitted instead of looking absent. Owned strings stop growing once they pass that budget. A later scalar that replaces user, objectRef, or responseStatus clears the earlier object. * fix(artifacts): chunk audit tokenization and depth-cutoff versions Ordinary lines are tokenized in 4 KiB slices. A depth overflow rereads that line one code unit at a time. When the cutoff hides apiVersion, request fields stay uninterpreted. A later array that replaces user, objectRef, or responseStatus clears the earlier object. * fix(artifacts): reread overflowed audit records from the start A depth overflow discarded every token in that slice, so identity later in the same record could be missed. Recognition keeps the first record's decoded slices and rereads them after an overflow. A scalar that replaces user.groups clears the earlier list. * fix(artifacts): stop replaying audit records once identity is known A depth overflow after auditID and stage no longer rereads the first record, and decoded slices are dropped once that identity is known. A replacement sourceIPs or groups list clears the previous list when it starts, including when the depth cap ends the replacement. * fix(artifacts): replay only the overflowed audit slice A depth overflow now rereads the failed slice one code unit at a time and the earlier slices in chunks, so a later stage key in that slice still wins. A cutoff before apiVersion suppresses request fields without labeling the version unsupported. * fix(artifacts): let a readable stage fill fields cut by depth A first stage whose request body hits the JSON depth cap observes no apiVersion, so its request fields are withheld. The sample still marked fieldsRecorded true because only a declared unsupported version counted, so a later readable stage for the same auditID never supplied the URI, verb, user, or object details. Gate both the flag and the later fill on suppressFields so depth-suppressed stages stay fillable. * fix(artifacts): clear audit budget omission when the final value fits A later duplicate that supplies a small user agent, URI, or list no longer leaves request_fields_omitted set for the value that was replaced. * fix(artifacts): drop audit budget omission when null replaces the value A later null or container for an owned field clears the budget-omission mark left by the value it replaces. * fix(artifacts): keep audit omission keys distinct and release replay slices Nested field omission no longer shares a key with a top-level property of the same spelling. Replacing a list with an object clears that list's budget mark. Recognition drops the first-record replay buffer when the line ends and when the probe finishes. * fix(artifacts): clear list budget marks and keep replay text until the line is read A later null for sourceIPs or groups clears that list's budget mark. Recognition keeps the first record's slices until that line has been tokenized, then drops them. * fix(artifacts): clear nested audit omissions and release failed replay text A later null or object for user.groups clears that list's budget mark, and a new user or objectRef object clears its child marks. Syntax failures drop the recognition replay buffer before the probe returns. * fix(artifacts): limit audit budget omission to request fields An over-budget apiVersion no longer sets request_fields_omitted. Replacing an objectRef field, or starting a new sourceIPs or groups list, clears that field's budget mark. * fix(artifacts): accept long zero-fraction audit response codes A status lexeme such as 200.00000000000000000 is still the safe integer 200. The number text bound is 64 characters, which covers that form and still rejects an unbounded digit string. * test(artifacts): cover audit response code number bounds The response code is now admitted by its numeric value instead of a 20-character text bound. Pin the two edges that keep the wider bound honest: the widest safe integer on both sides, an exponent form that evaluates to a safe integer, and a value past the safe range that is still dropped. * fix(artifacts): keep padded audit status codes and pending recognition Trailing zeros after a decimal do not drop an integral status code. A verb dropped by the text budget counts as unlisted. A recognition finish before the first line ends stays pending and keeps its replay text. * fix(artifacts): keep integral audit status exponents and probe padding A status code is the safe integer its lexeme evaluates to, including a fraction that an exponent cancels. Leading padding has its own recognition allowance, and a verb dropped before an unread API version stays out of the histogram. * fix(artifacts): keep audit status codes with a cancelling exponent A large exponent is rejected only when it cannot cancel to a safe integer inside the maximum line. The final shift still decides the code. --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>