# E-LINT-008: personal data or a secret in a log or span

Logs, standard output and spans leave the app and are kept, so personal data and secrets must never reach them, and since lint cannot tell which values are personal, it treats everything that comes from outside the app as personal: a form value or an uploaded file, a URL parameter, the request (its headers, cookies, URL, form and body), the viewer's identity from `auth.Viewer`, `Subject` included, a value scanned from the database, a mail read from the inbox, the name, contents or error of a stored file, the input of a page call, of a `Validate` hook or of a function the app serves to other apps, what another app's function returns, and the secret that `Reveal` of a `secrets.Value` returns. Lint follows such a value through strings, `fmt`, conversions, structs, slices, maps, channels, contexts, errors made with `errors.New` or `fmt.Errorf`, the setters of form fields, such as `SetError`, closures, global variables, what the data providers keep between requests, the app's own functions and methods, and the `String`, `Error`, `Format` and `MarshalJSON` methods that `fmt`, `log/slog` and `encoding/json` call on a value and on what it holds through pointers, elements, exported fields and embedded structs, and refuses every call that records it: the logging functions of `log/slog` (`Debug`, `Info`, `Warn`, `Error`, their `Context` forms, `Log`, `LogAttrs` and `With`), the same methods of `*slog.Logger` and its `WithGroup`, `Handle`, `WithAttrs` and `WithGroup` of a `slog.Handler`, `fmt.Print`, `fmt.Printf` and `fmt.Println`, the builtins `print` and `println`, the name passed to `telemetry.Start`, and the key and value passed to `SetAttr` of a span, also when the call goes through a variable, a method value or an interface method with the same name and signature. Numbers and booleans never carry outside data, so ids, counts, lengths, comparisons and flags may be recorded, but a hash of a value still carries it, and a struct, slice or map that holds outside data in one part counts as outside data as a whole. Its known limits are these: it does not enter an app method that the standard library calls with outside data, other than the `Scan` of a `sql.Scanner`, such as an `UnmarshalJSON` that logs its input; it does not follow a value kept between requests in an object that no hook's receiver reaches, such as one only `OnStart` holds, a write into an argument by a standard function that lint does not know writes into it, a value that holds text in a type it treats as clean: a `*time.Location` or a `time.Time` (`time.FixedZone(login, 0).String()`), a `*big.Int` (`SetBytes`, `Bytes`), a `[]uint16` (`utf16.Encode`) or a `[]int` of runes, nor a write into memory that a result shares with its argument, such as `bytes.TrimSpace(buf)` with `buf` or what `fmt.Append` returns with the slice it got, which the other does not see; and since it takes a call through an interface, and a call outside the app that it knows nothing more about, to pass every argument on to every result, the error of a call through an interface of the app carries the call's arguments, and the id that `mailer.Send` returns carries the message's outside data, so logging either is refused. An error that a hook, page call, RPC function or `OnStart` returns is not checked, and neither is `RecordError` of a span: the framework records an error's kinds and codes, never its text. Generated files are checked too, since they hold the code of the templates' expressions, such as `{{ log.With('q', form.Q.GetValue()) }}` with a `*slog.Logger` in `log`, and a problem there points to the template line that the code was written from.

**Fix:** remove the value from the log line, print or span, or log an id, a count or a code instead.
