Documentation
¶
Overview ¶
Package redact applies the workspace's redaction policy to operator-visible text and structured values.
Nothing is compiled in. What counts as a secret is a property of a workspace, not of this binary: four separate hardcoded pattern lists previously drifted apart and were wrong in both directions, over-redacting ordinary prose and missing credentials none of them happened to name. The policy comes from [privacy] in mivia.toml, recommended values ship in mivia.toml.example, and a workspace that configures nothing redacts nothing.
That fails open by design. See .agents/rules/10-security-privacy.md.
Index ¶
Constants ¶
const DefaultPlaceholder = "[redacted]"
DefaultPlaceholder is substituted for a match when the policy names none.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Policy ¶
type Policy struct {
// contains filtered or unexported fields
}
Policy is a compiled redaction policy. The zero value and a nil *Policy redact nothing, so a path that runs before SetPolicy - tests, `mivia version`, any tool constructed directly - is unredacted rather than falling back to a compiled list.
func Compile ¶
Compile builds a policy from configuration.
An invalid pattern is an error naming the offending expression, never a silently dropped rule: a policy that quietly omits half its patterns is worse than one that refuses to start, because the operator believes they are covered.
func Current ¶
func Current() *Policy
Current returns the installed policy, or nil when none is set.
func (*Policy) JSONValue ¶
JSONValue walks a decoded JSON value, replacing any value whose key matches the policy's key names and applying Text to the remaining string leaves. Strings are immutable, so leaves are replaced by their parent and the possibly-new value is returned.
func (*Policy) Text ¶
Text replaces every pattern match with the placeholder.
The placeholder is substituted verbatim (ReplaceAllLiteralString), never through regexp template expansion: the placeholder is operator-chosen text, and Go's Expand semantics would silently corrupt it - $0 re-emits the matched secret itself (the redaction echoing the exact text it exists to hide), while $1/${name} expand to empty or absent groups. JSONValue's key-elision path inserts the same placeholder literally, so both paths must agree on a literal placeholder.