Documentation
¶
Overview ¶
Package credential is Daisybell's one credential detector (SPEC invariant 7, docs/work/04). It says whether a form field holds a secret the human must type (passwords, one-time codes, card numbers and security codes) and whether its value must never be shown back to the AI (those, plus private data such as a CPF or an IBAN). The rules are data (rules.json): the guard, the recording mask, the outline and screenshot redaction use them here, and the Cockpit extension reads the same rules from a generated TypeScript module (see ts.go).
Index ¶
Constants ¶
const TSPath = "extension/src/shared/credential-rules.gen.ts"
TSPath is where the extension's copy of the rules lives, relative to the repository root.
Variables ¶
This section is empty.
Functions ¶
func Fold ¶
Fold lowercases s, strips the accents of Latin letters and collapses whitespace, so keyword lists can be written once without diacritics ("excluir", "contrasena", "codigo").
func Pattern ¶
Pattern is the regular expression matching any of the phrases as whole words. The same source compiles in Go (RE2) and in JavaScript with the u flag: the extension uses it as is.
func Sensitive ¶
Sensitive says whether the value of a field must never be shown back to the AI: a credential (Of) or private data (a CPF, an IBAN, any card detail, a transaction code).
func TSModule ¶
func TSModule() string
TSModule is the TypeScript module the Cockpit extension imports (TSPath): the same rules, with each kind's phrases already joined into the pattern Go compiles (Pattern), so both sides match with the very same regular expressions. TestTSModuleIsGenerated fails when the file is stale; `go test ./internal/credential -run TestTSModuleIsGenerated -update` rewrites it.
Types ¶
type Field ¶
type Field struct {
Tag string `json:"tag,omitempty"` // INPUT, TEXTAREA, SELECT, or "" for contenteditable
Type string `json:"type,omitempty"`
Autocomplete string `json:"autocomplete,omitempty"`
Name string `json:"name,omitempty"`
ID string `json:"id,omitempty"`
Label string `json:"label,omitempty"` // accessible name / label text
Placeholder string `json:"placeholder,omitempty"`
InputMode string `json:"inputmode,omitempty"`
MaxLength int `json:"maxlength,omitempty"`
// Filled reports whether the field currently has a value (the value itself is never read).
Filled bool `json:"filled,omitempty"`
// Masked is set when CSS hides what is typed (-webkit-text-security): a password in disguise.
Masked bool `json:"masked,omitempty"`
// Segments counts the one-character inputs in the field's group (a code split into boxes).
Segments int `json:"segments,omitempty"`
}
Field describes a form field (from the page, never its value).
type KindRule ¶
type KindRule struct {
Kind Kind `json:"kind"`
Phrases []string `json:"phrases"`
Unless []string `json:"unless,omitempty"`
}
KindRule is one kind recognised by name, id, label or placeholder.
type Rules ¶
type Rules struct {
Autocomplete map[string]Kind `json:"autocomplete"`
TextTypes []string `json:"textTypes"`
Kinds []KindRule `json:"kinds"`
Private struct {
AutocompletePrefixes []string `json:"autocompletePrefixes"`
Phrases []string `json:"phrases"`
} `json:"private"`
Accents map[string]string `json:"accents"`
}
Rules is the parsed rule data (rules.json).