Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
tyranid-sanitize
Advanced tools
`tyranid-sanitize` is a tool for obfuscating text fields on documents in your tyranid collections using simple schema annotations.
Readme
tyranid-sanitize
is a tool for obfuscating text fields on documents in your tyranid collections using simple schema annotations.
In order to mark fields to be sanitized, add the sanitize
property to a field definition.
import { Tyr } from 'tyranid';
export const Blog = new Tyr.Collection({
id: 'b00',
name: 'blog',
dbName: 'blogs',
fields: {
_id: { is: 'mongoid' },
/**
* we want to obfuscate the name when the database
* is passed to `tyranid-sanitize`, so we mark the field
* with `sanitize: 'name'` to generate a random name string
* using faker.js.
*/
name: { is: 'string', sanitize: 'name' },
organizationId: { link: 'organization' }
}
});
The sanitize
(see the type definition here: ./src/sanitize.ts) property can be one of the following:
true
: this will use the default sanitization (a random string of lorem ipsum)lorem
: a random sentence of lorem ipsumname
: a random nameemail
: a random emailAfter marking properties for sanitization, use the sanitize
function to create
a cloned, sanitized version of the database.
import { Tyr } from 'tyranid';
import { sanitize } from 'tyranid-sanitize';
// ... after booting tyranid
await sanitize(Tyr);
The sanitize(tyr: Tyr, opts?: SanitizeOptions)
function takes an optional options argument:
interface SanitizeOptions {
/**
* desired name of the output database
*/
outDbName?: string;
/**
* number of documents to batch insert at a time
*/
batchSize?: number;
/**
* verbose progress logging
*/
verbose?: boolean;
/**
* sanitize each collection serially (defaults to concurrently)
*/
serial?: boolean;
/**
* faker.js seed
*/
seed?: number;
/**
* sanitize every string field automatically
*/
autoSanitize?: boolean;
}
FAQs
`tyranid-sanitize` is a tool for obfuscating text fields on documents in your tyranid collections using simple schema annotations.
The npm package tyranid-sanitize receives a total of 6 weekly downloads. As such, tyranid-sanitize popularity was classified as not popular.
We found that tyranid-sanitize demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.