Skip to content

mongoshield mask

Find personal data and suggest mask rules for copy/pull (suggest).

Terminal window
mongoshield mask <action> [options]

mask suggest samples every collection (--sample documents each, read-only, from a secondary when there is one) and detects personal data by value patterns and field names: emails, phones, names, addresses, postal codes, card numbers, IBANs, IP addresses, national ids, dates of birth, secrets, geolocation, and free text that contains emails or phones. It prints one suggested rule per field, in the mask file format, ordered by confidence. With --mask it marks fields that file already covers; --write adds the new rules to it (JSON files are merged; TypeScript/JavaScript files are created when missing, and never rewritten: the snippet is printed instead).

Detection works on samples and patterns: review the rules before copying.

ArgumentDescription
<action>requiredsuggest
OptionDescription
--from <mongodb-uri>Sample this deployment (default: the configured source / MONGODB_URI).
--include <pattern>Only these namespaces, e.g. app.* or app.users. Repeatable.
--exclude <pattern>Skip these namespaces, e.g. *.audit_*. Repeatable.
--sample <n>Documents sampled per collection (1–10000). Default: 1000.
--min-confidence <0..1>Leave out findings below this confidence. Default: 0.5.
--mask <file>The current mask file: covered fields are marked, --write updates it.
--writeAdd the new rules to the --mask file (created if missing).

The global options (--config, --json, --quiet, --verbose, --no-color, --yes) work here too.

Suggest rules for the app database:

Terminal window
mongoshield mask suggest --from $PROD_URI --include 'app.*'

Check an existing mask file for fields it misses:

Terminal window
mongoshield mask suggest --include 'app.*' --mask ./mask.ts

Draft a mask file, then review it and copy with it:

Terminal window
mongoshield mask suggest --include 'app.*' --mask ./mask.json --write