Argus.Extractors.EctoSchema (Panoptes v0.13.0)

Copy Markdown View Source

Ecto schema fields, and which of them are redacted.

redact: true excludes a field from inspect/1. It defaults to off, so a struct holding a credential prints it in full — into logs, crash reports, LiveView debug output and whatever error reporter is installed. Nothing at the field's definition site suggests that.

Both lists are compiled into __schema__/1, which dispatches on its argument with a select_val and returns a literal per key:

{:select_val, {:x, 0}, {:f, 12},
  {:list, [atom: :fields, f: 20, atom: :redact_fields, f: 19, ...]}}
...
{:label, 20}
{:move, {:literal, [:id, :smtp_password, ...]}, {:x, 0}}
:return

So this reads the module rather than calling it. Loading a project's modules to ask them questions would run their @on_load and module bodies in the analyzer, which is not a thing an analysis should do to code it was pointed at.

Emitted facts

  • schema_field(mod, field) — a persisted field
  • redacted_field(mod, field) — one excluded from inspect/1