Documentation
¶
Index ¶
Constants ¶
const ( // MaxPayloadBytes caps the serialized captured payload record. The fit // test applies to the WHOLE serialized record, not the content alone: // JSON escaping can inflate content substantially. MaxPayloadBytes = 64_000 // InputHardCapBytes bounds the raw canonical input this package will // process at all. InputHardCapBytes = 1 << 20 )
const RedactedPlaceholder = "[REDACTED_SECRET]"
RedactedPlaceholder replaces every redacted key value and pattern match.
Variables ¶
var ( // RedactorVersion identifies the ruleset that produced redacted bytes. // It is reported on every captured payload record and always comes from // the embedded artifact, never from a separate constant. RedactorVersion string )
Functions ¶
func CanonicalJSON ¶
CanonicalJSON serializes a JSON value into its RFC 8785 (JCS) canonical form. Canonical bytes are the input to every payload fingerprint, so the output must be byte-identical across implementations; the vectors in testdata/jcs-vectors.json pin that behavior.
func RedactJSON ¶
RedactJSON returns a deep copy of value with credential-looking content replaced by RedactedPlaceholder: values of sensitive keys are replaced wholesale, and every string value is run through the ruleset's value patterns. The input is never mutated. Redaction is coverage-oriented — the guarantee is that a matched secret does not survive, not that every engine produces identical bytes.
Types ¶
type FailureReason ¶
type FailureReason string
FailureReason explains a capture_failed record. Failures never carry payload content.
const ( ReasonSerializationError FailureReason = "serialization_error" ReasonRedactionError FailureReason = "redaction_error" ReasonSizePrecheckExceeded FailureReason = "size_precheck_exceeded" ReasonInvalidPayload FailureReason = "invalid_payload" )
type Mode ¶
type Mode string
Mode controls how much of a tool payload is captured. It is org policy, resolved elsewhere; this package only executes it.
const ( // ModeOmitted records that a payload existed and how large it was, // without content and without a fingerprint. ModeOmitted Mode = "omitted" // ModeSummary is the default: no captured payload record is produced. ModeSummary Mode = "summary" // ModeFull captures the redacted payload, truncating oversized content. ModeFull Mode = "full" )
func NormalizeMode ¶
NormalizeMode maps an org-policy mode string to a Mode. Absent ("") or unrecognized values normalize to ModeSummary: an unknown mode must never mean "send content".
type Payload ¶
type Payload struct {
Mode string
Value map[string]any
Preview string
Redacted bool
Reason FailureReason
SourceSha256 string
SourceByteLength int
StoredSha256 string
StoredByteLength int
// contains filtered or unexported fields
}
Payload is one captured tool payload record. Exactly one of the shapes implied by Mode is serialized; illegal field combinations are not representable on the wire (see MarshalJSON).
func Capture ¶
Capture turns a decoded tool payload into a captured payload record.
It returns nil when nothing should be recorded: empty input, summary mode, or an unrecognized mode (unknown never means "send content"). Every error path returns a capture_failed record and never any input content. The returned record does not alias the input: mutating input after Capture cannot change the record, and vice versa.
func (Payload) MarshalJSON ¶
MarshalJSON emits only the fields that belong to the record's mode.
It uses a value receiver on purpose: encoding/json only finds pointer-receiver marshalers on addressable values, and a value receiver works for both Payload and *Payload. Output is encoded without HTML escaping so serializedSize measures what JSON consumers measure.