Expand description
The data-mask node — masks sensitive fields in the request before they
reach loggers or the upstream: query parameters, headers, and JSON body
fields can be removed, replaced with a fixed value, or partially rewritten
with a regex substitution.
Port of APISIX’s data-mask plugin. Deviations from the Lua original:
- Body rules support
body_format: jsononly;urlencodedis rejected at config load. - Body field selection uses dotted paths (
user.cards.0.number), not JSONPath — no$..recursive descent or wildcards. A leading$.is tolerated and stripped. Purely numeric segments index into arrays. - APISIX runs this in the log phase (masking what loggers see); featherbit
runs it wherever the node sits in the graph — place it before
loggingand/orupstreamnodes that must not see the raw values.
Structs§
- Data
Mask Plugin - Masks request query parameters, headers, and JSON body fields according
to a list of rules. Masking is best-effort and never fails at execution
time: bodies that are absent, non-JSON, or larger than
max_body_sizesimply skip the body rules. The plugin only touchescontext.request; it never writescontext.messageorcontext.errors. - Mask
Rule 🔒 - One masking rule from the
requestarray.
Enums§
- Action 🔒
- What a rule does to the matched field.
- PathSeg 🔒
- One segment of a dotted body path.
- Target 🔒
- Where a rule applies.
Functions§
- apply_
to_ 🔒json - Applies
actionto the value addressed bypathinside a parsed JSON document. Returnstrueif anything changed. Paths that do not resolve (missing key, out-of-range index, type mismatch) are silently skipped, as are regex actions on non-string values — mirroring the Lua plugin’s warn-and-continue behavior. - apply_
to_ 🔒multimap - Applies a rule to a multi-valued map (query params or headers). Regex
actions run against every value of the field;
replacecollapses the field to the single configured value. - parse_
dotted_ 🔒path - Parses a dotted path (
user.cards.0.number), tolerating a leading$.or$. Purely numeric segments become array indices. Empty segments (e.g.a..b) are rejected. - parse_
rule 🔒 - Parses and validates one rule object, compiling regexes and dotted paths.
- regex_
mask 🔒 - Replaces the first regex match in
swithreplacement(which may use$1-style capture references). Returnstrueif a match was rewritten.