mongoshield mask
Find personal data and suggest mask rules for copy/pull (suggest).
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.
Arguments
Section titled “Arguments”| Argument | Description | |
|---|---|---|
<action> | required | suggest |
Options
Section titled “Options”| Option | Description |
|---|---|
--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. |
--write | Add the new rules to the --mask file (created if missing). |
The global options (--config, --json, --quiet,
--verbose, --no-color, --yes) work here too.
Examples
Section titled “Examples”Suggest rules for the app database:
mongoshield mask suggest --from $PROD_URI --include 'app.*'Check an existing mask file for fields it misses:
mongoshield mask suggest --include 'app.*' --mask ./mask.tsDraft a mask file, then review it and copy with it:
mongoshield mask suggest --include 'app.*' --mask ./mask.json --writeMongoShield is MIT licensed and is not affiliated with, endorsed by or sponsored by MongoDB, Inc. MongoDB is a trademark of MongoDB, Inc.Privacy policy