### Apple Container System Setup Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/demo/README.md Required kernel configuration for Apple Container. ```bash container system kernel set --recommended ``` -------------------------------- ### Example configuration template Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/generating-configuration.md A sample YAML template file used as the base for the configuration generation process. ```yaml common: pg_bin_path: "/usr/lib/postgresql/18/bin" tmp_dir: "/tmp" restore: pg_restore_options: clean: true inserts: true on-conflict-do-nothing: true restore-in-order: true jobs: 10 dump: pg_dump_options: exclude-schema: "(pg_*|tiger|tiger_data|topology)" exclude-table-data: - "public.messenger_messages" clean: true create: true if-exists: true jobs: 10 ``` -------------------------------- ### Install GreenmaskBundle via Composer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/installation.md Use this command to add the bundle to your project dependencies. ```bash composer require tacticmedia/greenmask-bundle ``` -------------------------------- ### Docker build configuration generation Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/generating-configuration.md Example of running the configuration generation during a Docker image build process. ```dockerfile COPY greenmask/config.dist.yml /tmp/config.dist.yml RUN composer install --prefer-dist --no-progress --no-interaction --no-scripts \ && bin/console greenmask:generate-config /tmp/config.dist.yml /tmp/config.yml \ && rm -f /tmp/config.dist.yml ``` -------------------------------- ### Configure Cmd Transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/multi-column.md Examples of configuring the Cmd transformer using PHP attributes and YAML syntax. ```php #[Transformer\Cmd( executable: '/usr/local/bin/anonymise', args: ['--strict'], columns: [['name' => 'note', 'skip_on_null_input' => true]], driver: CmdDriverEnum::JSON, timeout: '30s', )] ``` ```yaml - name: Cmd params: executable: /usr/local/bin/anonymise args: ['--strict'] columns: - name: note skip_on_null_input: true driver: { name: json } timeout: 30s ``` -------------------------------- ### Generated Greenmask Configuration Example Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/README.md The resulting YAML configuration file generated from the entity attributes. ```yaml dump: transformation: - schema: core name: user transformers: - name: Masking params: type: name column: display_name - name: RandomEmail when: 'record.email != "admin@example.com"' params: domains: - disabled.localhost column: email ``` -------------------------------- ### Configure faker family transformers Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/datetime.md Examples of applying faker-style date transformers to fields. ```php #[Transformer\RandomMonthName] #[Transformer\RandomTimezone(keepNull: false)] ``` -------------------------------- ### Configure RandomUuid Transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/identity.md Example of applying the RandomUuid transformer using a PHP attribute. ```php #[Transformer\RandomUuid] ``` -------------------------------- ### Configure RandomPerson Transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/multi-column.md Example of using the RandomPerson transformer with column templates and gender mapping. ```php #[Transformer\RandomPerson( columns: [['name' => 'fullName', 'template' => '{{ .Title }} {{ .FirstName }} {{ .LastName }}']], genderMapping: ['Male' => ['m', 'man'], 'Female' => ['f', 'woman']], )] ``` -------------------------------- ### Configure Faker Family Transformers Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/identity.md Examples of applying various faker-based transformers using PHP attributes. ```php #[Transformer\RandomUsername] #[Transformer\RandomE164PhoneNumber(keepNull: false)] ``` -------------------------------- ### Configure RandomEmail Transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/identity.md Examples showing how to define the RandomEmail transformer using PHP attributes or YAML configuration. ```php #[Transformer\RandomEmail(preserve: ['admin@example.com'], domains: ['disabled.localhost'])] ``` ```yaml - name: RandomEmail when: 'record.email != "admin@example.com"' params: domains: [disabled.localhost] column: email ``` -------------------------------- ### Configure Json Transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/advanced.md Examples of configuring the Json transformer to edit document fields using PHP attributes or YAML configuration. ```php #[Transformer\Json([ ['operation' => JsonOperationEnum::SET, 'path' => 'name', 'value' => 'REDACTED'], ['operation' => JsonOperationEnum::SET, 'path' => 'crew.size', 'value_template' => '{{ randomInt 1 10 }}'], ['operation' => JsonOperationEnum::DELETE, 'path' => 'ssn', 'skip_not_exist' => true], ])] ``` ```yaml - name: Json params: operations: - operation: set path: name value: REDACTED - operation: set path: crew.size value_template: '{{ randomInt 1 10 }}' - operation: delete path: ssn skip_not_exist: true column: document ``` -------------------------------- ### Run the Greenmask demo Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/demo/README.md Executes the end-to-end demonstration using the provided Makefile command. ```bash make demo ``` -------------------------------- ### Manual Makefile Commands Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/demo/README.md Commands for managing the demo environment via Docker Compose. ```bash docker compose up -d database ``` ```bash docker compose run --rm app composer install ``` ```bash docker compose run --rm app bin/console demo:seed ``` ```bash docker compose run --rm app bin/console greenmask:generate-config greenmask/config.dist.yaml greenmask/config.yaml ``` ```bash docker compose run --rm greenmask --config=/config/config.yaml validate --data --diff --transformed-only --rows-limit=3 ``` ```bash docker compose run --rm greenmask --config=/config/config.yaml dump ``` ```bash docker compose run --rm greenmask --config=/config/config.yaml list-dumps ``` ```bash docker compose run --rm greenmask --config=/config/config.yaml restore latest ``` ```bash docker compose run --rm app bin/console demo:show ``` -------------------------------- ### Apple Container Database Readiness Check Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/demo/README.md Wait loop for database readiness in Apple Container. ```bash until container exec database pg_isready ...; do sleep 1; done ``` -------------------------------- ### List and restore database dumps Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/backup-and-restore.md Commands to list available dumps in storage and restore the latest version. ```bash greenmask --config=/tmp/config.yml list-dumps greenmask --config=/tmp/config.yml restore latest ``` -------------------------------- ### Run project development commands Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/CLAUDE.md Use these Composer and Makefile commands for testing, static analysis, code style enforcement, and end-to-end verification. ```bash composer install composer test # PHPUnit; single test: vendor/bin/phpunit --filter testName composer stan # PHPStan level 8 over src and tests composer cs # php-cs-fixer (@auto, @PhpCsFixer, @Symfony) composer qa # rector, cs, stan, test in sequence cd demo && make demo # end-to-end round trip on Docker Compose cd demo && make RUNNER=container demo # the same on Apple Container ``` -------------------------------- ### Generate configuration command Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/generating-configuration.md Execute the generation command by providing a source template and a destination file path. ```bash bin/console greenmask:generate-config ``` -------------------------------- ### Apple Container Runner Execution Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/demo/README.md Command to execute the demo using the Apple Container runner. ```bash make RUNNER=container demo ``` -------------------------------- ### Restrict bundle to specific environments Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/installation.md Limit the bundle registration to non-production environments to prevent the command from being available in production. ```php TacticMedia\GreenmaskBundle\GreenmaskBundle::class => ['dev' => true, 'test' => true], ``` -------------------------------- ### Execute Greenmask dump Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/backup-and-restore.md Run the dump command using a specific configuration file. ```bash greenmask --config=/tmp/config.yml dump ``` -------------------------------- ### Generate Greenmask Configuration Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/README.md Execute the console command to transform entity attributes into a Greenmask configuration file. ```bash bin/console greenmask:generate-config config/greenmask.dist.yml config/greenmask.yml ``` -------------------------------- ### Apply RandomMac Transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/network.md Configures the RandomMac transformer to preserve the original vendor prefix. ```php #[Transformer\RandomMac(keepOriginalVendor: true)] ``` -------------------------------- ### Implement MultiColumnTransformerInterface Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/multi-column.md Create a custom transformer by implementing the MultiColumnTransformerInterface and using the ColumnsShape utility to resolve column mappings. ```php #[\Attribute(\Attribute::TARGET_CLASS)] final readonly class RandomCouple implements MultiColumnTransformerInterface { /** @param non-empty-list $columns */ public function __construct(private array $columns) {} public function getYamlValue(array $columns): array { return YamlEntry::build('RandomCouple', params: [ 'columns' => ColumnsShape::resolve($this->columns, $columns, self::class), ]); } } ``` -------------------------------- ### Register the bundle in bundles.php Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/installation.md Manually register the bundle if Symfony Flex does not automatically handle the configuration. ```php return [ // ... TacticMedia\GreenmaskBundle\GreenmaskBundle::class => ['all' => true], ]; ``` -------------------------------- ### Run Greenmask dump via Docker Compose Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/backup-and-restore.md Execute the dump command inside the configured Docker container. ```bash docker compose -f compose.greenmask.yaml run --rm greenmask dump ``` -------------------------------- ### Apply RandomDomainName and RandomURL Transformers Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/network.md Applies the RandomDomainName and RandomURL transformers to generate synthetic network identifiers. ```php #[Transformer\RandomDomainName] #[Transformer\RandomURL] ``` -------------------------------- ### Apply RandomIp Transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/network.md Configures the RandomIp transformer with a specific CIDR subnet. ```php #[Transformer\RandomIp(subnet: '10.0.0.0/8')] ``` -------------------------------- ### Cmd Transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/multi-column.md Pipes the row through an external program. ```APIDOC ## Cmd ### Description Pipes the row through an external program. The executable must exist on the machine that runs the dump. ### Parameters - **executable** (string) - Required - The path to the external program. - **args** (list) - Optional - Arguments for the executable. - **columns** (list) - Optional - Column definitions including name and skip flags. - **driver** (CmdDriverEnum) - Optional - Driver name (TEXT, JSON, CSV). - **jsonDataFormat** (CmdJsonDataFormatEnum) - Optional - JSON data format. - **jsonAttributesFormat** (CmdJsonAttributesFormatEnum) - Optional - JSON attributes format. - **csvAttributesFormat** (CmdCsvAttributesFormatEnum) - Optional - CSV attributes format. - **validate** (bool) - Optional - Validation flag. - **timeout** (string) - Optional - Execution timeout (e.g., '30s'). - **expectedExitCode** (int) - Optional - Expected exit code. - **skipOnBehaviour** (CmdSkipBehaviourEnum) - Optional - Skip behavior (ALL, ANY). - **when** (string) - Optional - Top-level condition. ``` -------------------------------- ### Configure RandomPerson transformer in YAML Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/multi-column.md Define the RandomPerson transformer configuration using YAML, specifying column names and templates. ```yaml - name: RandomPerson params: columns: - name: first_name template: '{{ .FirstName }}' - name: last_name template: '{{ .LastName }}' ``` -------------------------------- ### Configure RandomString Transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/text.md Applies a random string generator with specified minimum and maximum length constraints. ```php #[Transformer\RandomString(minLength: 8, maxLength: 16)] ``` -------------------------------- ### Configure RandomParagraph Transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/text.md Applies a Lorem-style paragraph generator for filler text content. ```php #[Transformer\RandomParagraph] ``` -------------------------------- ### Apply Finance Transformers via Attributes Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/finance.md Use PHP attributes to apply RandomCCNumber and RandomAmountWithCurrency transformers to class properties. ```php #[Transformer\RandomCCNumber] #[Transformer\RandomAmountWithCurrency(keepNull: false)] ``` -------------------------------- ### RandomString Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/text.md Generates a random string with a controllable length and optional engine configuration. ```APIDOC ## RandomString ### Description Generates a random string of characters. This is the only text transformer that supports a configurable length and engine. ### Attributes - **minLength** (int) - Required - The minimum length of the generated string. - **maxLength** (int) - Required - The maximum length of the generated string. - **symbols** (string) - Optional - The alphabet of characters to draw from. - **keepNull** (bool) - Optional - Whether to preserve null values. - **engine** (EngineEnum) - Optional - The engine used for generation. - **when** (string) - Optional - Conditional logic for the transformation. ``` -------------------------------- ### Configure Template Transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/advanced.md Configures the Template transformer to replace a column value using a Go template. ```php #[Transformer\Template('{{ .GetColumnValue "first_name" }} {{ .GetColumnValue "last_name" }}')] ``` -------------------------------- ### RandomDomainName and RandomURL Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/network.md Generates random domain names or URLs from a generic pool. ```APIDOC ## RandomDomainName / RandomURL ### Description Generates a random domain name or URL. Note that generated domains may resolve and should be treated as unsafe to contact. ### Parameters - **keepNull** (bool) - Optional - Whether to keep null values. - **when** (string) - Optional - Top-level condition for applying the transformer. ``` -------------------------------- ### RandomMac Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/network.md Generates a random MAC address with optional vendor preservation and cast/management type settings. ```APIDOC ## RandomMac ### Description Generates a random MAC address. Optionally preserves the original vendor's first three octets. ### Parameters - **keepOriginalVendor** (bool) - Optional - If true, keeps the first three octets of the original MAC. - **castType** (MacCastTypeEnum) - Optional - Cast type (ANY, INDIVIDUAL, GROUP). Defaults to any. - **managementType** (MacManagementTypeEnum) - Optional - Management type (ANY, UNIVERSAL, LOCAL). Defaults to any. - **engine** (EngineEnum) - Optional - The engine used for generation. - **when** (string) - Optional - Top-level condition for applying the transformer. ``` -------------------------------- ### Define a SQL Script Attribute Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/attributes.md Use the Query attribute to define SQL statements for pre or post dump execution. Note that the current generator does not yet process these attributes. ```php #[Script\Query(name: 'clear_sessions', query: 'DELETE FROM sessions', when: 'after')] ``` -------------------------------- ### Configure NoiseDate transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/datetime.md Shifts original date values by a specified interval range. ```php #[Transformer\NoiseDate(maxRatio: '6 months', minRatio: '1 day')] ``` -------------------------------- ### Hash Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/replacement.md Writes a digest of the original value, ensuring equal inputs result in equal outputs. ```APIDOC ## Hash ### Description Writes a digest of the original value, so equal inputs stay equal. ### Arguments - **salt** (string) - Optional - A hex string salt. Defaults to GREENMASK_GLOBAL_SALT. - **function** (HashFunctionEnum) - Optional - The hashing algorithm to use. Defaults to sha3-254 (SHA3-256). - **maxLength** (int) - Optional - Truncates the digest; 0 keeps it whole. - **when** (string) - Optional - Conditional logic for applying the transformer. ``` -------------------------------- ### Apply NoiseInt transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/numeric.md Shifts an integer value by a random ratio within defined bounds. ```php #[Transformer\NoiseInt(maxRatio: 0.3, min: 0)] ``` -------------------------------- ### Implement a Custom Transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/attributes.md Create a custom transformer by implementing TransformerInterface on an attribute class. The generator automatically discovers these via the interface. ```php #[\Attribute(\Attribute::TARGET_PROPERTY)] final readonly class RandomPostcode implements TransformerInterface { public function __construct(private string $country) {} public function getYamlValue(string $column): array { return YamlEntry::build('RandomPostcode', params: ['country' => $this->country]); } } ``` -------------------------------- ### Configure RandomDate transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/datetime.md Defines a random date range using min and max bounds. ```php #[Transformer\RandomDate(min: '2020-01-01 00:00:00', max: '2030-01-01 00:00:00')] ``` -------------------------------- ### RandomWord, RandomSentence, RandomParagraph Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/text.md Generates lorem-style filler text of increasing size, useful for layout testing. ```APIDOC ## RandomWord, RandomSentence, RandomParagraph ### Description Generates filler text content. These transformers do not accept length constraints or engines. ### Attributes - **keepNull** (bool) - Optional - Whether to preserve null values. - **when** (string) - Optional - Conditional logic for the transformation. ``` -------------------------------- ### RandomIp Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/network.md Generates a random IP address within a specified CIDR subnet. ```APIDOC ## RandomIp ### Description Generates a random IP address within a specified CIDR block. The address family of the subnet determines if the output is IPv4 or IPv6. ### Parameters - **subnet** (string) - Required - A CIDR block the address falls inside. - **engine** (EngineEnum) - Optional - The engine used for generation. - **when** (string) - Optional - Top-level condition for applying the transformer. ``` -------------------------------- ### TemplateRecord Transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/multi-column.md Writes several columns from one Go template over the whole record. ```APIDOC ## TemplateRecord ### Description Writes several columns from one Go template over the whole record. ### Parameters - **template** (string) - Required - The Go template string. - **columns** (list) - Optional - List of entity property names. - **validate** (bool) - Optional - Prints the transformation during a dump. - **when** (string) - Optional - Top-level condition. ``` -------------------------------- ### RegexpReplace Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/replacement.md Substitutes a pattern inside the original value using RE2 syntax. ```APIDOC ## RegexpReplace ### Description Substitutes a pattern inside the original value. The pattern uses RE2 syntax, which does not support backreferences or lookaround. ### Arguments - **regexp** (string) - Required - The regular expression pattern to match. - **replace** (string) - Required - The replacement string, supporting capture groups like $1. - **when** (string) - Optional - Conditional logic for applying the transformer. ``` -------------------------------- ### Configure RandomUnixTimestamp transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/datetime.md Generates a random Unix timestamp within specified bounds and units. ```php #[Transformer\RandomUnixTimestamp( min: 1600000000, max: 1700000000, unit: TimestampUnitEnum::MILLISECOND, )] ``` -------------------------------- ### Dict Transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/replacement.md Maps existing values to new values using a dictionary, with support for a default fallback. ```php #[Transformer\Dict( values: ['active' => 'inactive', 'pending' => '\N'], default: 'unknown', )] ``` ```yaml - name: Dict params: values: { active: inactive, pending: \N } default: unknown column: status ``` -------------------------------- ### Greenmask Docker Compose configuration Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/backup-and-restore.md Define the Greenmask service in Docker Compose, including volume mounts and environment variables for database and S3 storage connectivity. ```yaml services: greenmask: image: greenmask/greenmask volumes: - ./greenmask/config.yml:/tmp/config.yml environment: # Connection to the source database. # https://docs.greenmask.io/latest/configuration/#postgres-connection-variables PGHOST: ${PGHOST:-database} PGPORT: ${PGPORT:-5432} PGUSER: ${PGUSER:-app} PGPASSWORD: ${PGPASSWORD:-password} PGDATABASE: ${PGDATABASE:-app} # Every configuration key has an environment variable: uppercase it and # replace the dots with underscores. # https://docs.greenmask.io/latest/configuration/#environment-variable-configuration STORAGE_TYPE: "s3" STORAGE_S3_ENDPOINT: http://localstack:4566 STORAGE_S3_BUCKET: "greenmask" STORAGE_S3_REGION: "ap-southeast-2" STORAGE_S3_ACCESS_KEY_ID: "localstack" STORAGE_S3_SECRET_ACCESS_KEY: "localstack" STORAGE_S3_FORCE_PATH_STYLE: true DUMP_PG_DUMP_OPTIONS_DBNAME: "app" RESTORE_PG_RESTORE_OPTIONS_DBNAME: "app_restored" ``` -------------------------------- ### RandomCompany Transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/multi-column.md Configures the RandomCompany transformer to generate synthetic company names and suffixes. ```APIDOC ## RandomCompany ### Description Generates synthetic company data (CompanyName, CompanySuffix) for specified columns. ### Parameters - **columns** (non-empty-list) - Required - List of column definitions containing 'name' and 'template'. - **engine** (EngineEnum) - Optional - Transformation engine. - **when** (string) - Optional - Conditional execution logic. ``` -------------------------------- ### RandomChoice Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/replacement.md Picks one of the values from a provided list. ```APIDOC ## RandomChoice ### Description Picks one of the values you list. ### Arguments - **values** (non-empty-list) - Required - The list of values to choose from. - **validate** (bool) - Optional - Whether to validate the input. Defaults to true. - **keepNull** (bool) - Optional - Whether to keep null values. - **engine** (EngineEnum) - Optional - The engine to use for selection. - **when** (string) - Optional - Conditional logic for applying the transformer. ``` -------------------------------- ### RealAddress Transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/multi-column.md Configures the RealAddress transformer to generate synthetic address components. ```APIDOC ## RealAddress ### Description Generates synthetic address data (Address, City, State, PostalCode, Latitude, Longitude) for specified columns. ### Parameters - **columns** (non-empty-list) - Required - List of column definitions containing 'name' and 'template'. - **when** (string) - Optional - Conditional execution logic. ``` -------------------------------- ### Apply RandomInt transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/numeric.md Generates a random integer within the specified range. ```php #[Transformer\RandomInt(min: 1, max: 100)] ``` -------------------------------- ### Generated transformation output Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/generating-configuration.md The structure of the transformation rules emitted by the generator for entity tables. ```yaml dump: transformation: - schema: core name: user transformers: - name: Masking params: type: name column: display_name ``` -------------------------------- ### Replace Transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/replacement.md Writes a fixed value to every row in the column. ```php #[Transformer\Replace('REDACTED')] ``` -------------------------------- ### Apply RandomFloat transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/numeric.md Generates a random float with a defined number of decimal places. ```php #[Transformer\RandomFloat(min: 0.0, max: 99.99, decimal: 2)] ``` -------------------------------- ### Dict Transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/replacement.md Replaces each value based on a provided mapping dictionary. ```APIDOC ## Dict ### Description Replaces each value with the one mapped in the values dictionary. ### Parameters - **values** (array) - Required - A map of original values to new values. Use '\N' to represent NULL. - **default** (string) - Optional - The value to use when no key matches. - **failNotMatched** (bool) - Optional - If true, stops the dump on an unmapped value. Defaults to true. - **validate** (bool) - Optional - Whether to validate the output. - **when** (string) - Optional - Conditional logic for applying the transformer. ``` -------------------------------- ### Template Transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/advanced.md The Template transformer replaces a column's value with the output of a Go template. ```APIDOC ## Template Transformer ### Description Replaces one column with the output of a Go template, allowing derivation of one column from others. ### Parameters - **template** (string) - Required - The Go template string used to generate the value. - **validate** (bool) - Optional - Reserved for configuration compatibility. - **when** (string) - Optional - Conditional logic for the transformer. ``` -------------------------------- ### RandomPerson Transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/multi-column.md Configures the RandomPerson transformer to generate synthetic personal data based on specified templates and gender mapping. ```APIDOC ## RandomPerson ### Description Generates synthetic personal data (FirstName, LastName, Title) for specified columns. ### Parameters - **columns** (non-empty-list) - Required - List of column definitions containing 'name' and 'template'. - **gender** (GenderEnum) - Optional - Specifies gender (MALE, FEMALE, ANY). Defaults to ANY. - **genderMapping** (array>) - Optional - Maps original values to gender categories. - **fallbackGender** (GenderEnum) - Optional - Gender to use if mapping fails. - **engine** (EngineEnum) - Optional - Transformation engine. - **when** (string) - Optional - Conditional execution logic. ``` -------------------------------- ### Apply RandomLatitude and RandomLongitude attributes Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/geo.md Use these attributes to generate random geographic coordinates independently on a row. ```php #[Transformer\RandomLatitude] #[Transformer\RandomLongitude] ``` -------------------------------- ### Apply RandomNumeric transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/numeric.md Handles high-precision numeric or decimal columns by passing bounds as strings. ```php #[Transformer\RandomNumeric(min: '0.01', max: '99999999999999999999.99', decimal: 2)] ``` -------------------------------- ### Replace Transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/replacement.md Writes a fixed value to every row in the column. ```APIDOC ## Replace ### Description Replaces all values in the column with a single fixed value. ### Parameters - **value** (mixed) - Optional - The value to write. Defaults to 'CONFIDENTIAL'. - **validate** (bool) - Optional - Checks the value against the column type. - **keepNull** (bool) - Optional - Whether to preserve existing NULL values. - **when** (string) - Optional - Conditional logic for applying the transformer. ``` -------------------------------- ### Apply RandomBool transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/numeric.md Generates a random boolean value. ```php #[Transformer\RandomBool] ``` -------------------------------- ### Hash Transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/replacement.md Generates a cryptographic digest of the input value. Supports various hashing algorithms and optional salt. ```php #[Transformer\Hash(function: HashFunctionEnum::SHA256, maxLength: 16)] ``` -------------------------------- ### SetNull Transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/replacement.md Writes NULL to a column. The column must be nullable. ```APIDOC ## SetNull ### Description Writes NULL to the target column. The column must be nullable. ### Parameters - **when** (string) - Optional - Conditional logic for applying the transformer. ``` -------------------------------- ### Apply NoiseNumeric transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/numeric.md Shifts a high-precision numeric value by a random ratio, accepting string bounds for precision. ```php #[Transformer\NoiseNumeric(maxRatio: 0.5, min: '0.0000000001')] ``` -------------------------------- ### RegexpReplace Transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/replacement.md Performs pattern-based substitution using RE2 syntax. Capture groups are supported via $1, $2, etc. ```php #[Transformer\RegexpReplace(regexp: '^(\w+)@.*$', replace: '$1@disabled.localhost')] ``` -------------------------------- ### RandomChoice Transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/replacement.md Selects a single value from a provided list of options. ```php #[Transformer\RandomChoice(values: ['red', 'green', 'blue'])] ``` -------------------------------- ### Transformer\Masking Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/replacement.md The Masking transformer allows for partial obscuring of data based on predefined rules. ```APIDOC ## Transformer\Masking ### Description Stars out part of the original value, keeping its shape. This transformer is applied via the `#[Transformer\Masking(PartialEnum::NAME)]` attribute. ### Arguments - **type** (PartialEnum) - Optional - The masking rule to apply. Defaults to `default`. - **when** (string) - Optional - Top-level condition for applying the mask. ### Supported Masking Rules | Case | Emitted value | Rule | |---|---|---| | `DEFAULT` | `default` | Replaces every character with `*` | | `NAME` | `name` | Masks the second and third letter of a word | | `PASSWORD` | `password` | Always returns a fixed-length mask | | `ADDRESS` | `addr` | Keeps the first 6 letters | | `EMAIL` | `email` | Keeps the domain and the first 3 letters | | `MOBILE` | `mobile` | Masks 3 digits from the 4th | | `TELEPHONE` | `tel` | Masks the last 4 digits and reformats | | `ID` | `id` | Masks the last 4 digits | | `CREDIT_CARD` | `credit_card` | Masks 6 digits from the 7th | | `URL` | `url` | Masks the password part of the URL | | `POSTCODE` | `postcode` | Keeps the first 2 characters | ``` -------------------------------- ### SetNull Transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/replacement.md Applies a NULL value to a nullable column. ```php #[Transformer\SetNull] ``` -------------------------------- ### Apply RandomPerson transformer to an entity Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/multi-column.md Use the RandomPerson attribute on an entity class to map generated values to multiple properties. ```php #[ORM\Entity] #[ORM\Table(name: 'customer', schema: 'core')] #[Transformer\RandomPerson(columns: [ ['name' => 'firstName', 'template' => '{{ .FirstName }}'], ['name' => 'lastName', 'template' => '{{ .LastName }}'], ])] class Customer { #[ORM\Column(name: 'first_name')] private string $firstName; #[ORM\Column(name: 'last_name')] private string $lastName; } ``` -------------------------------- ### Apply Masking Transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/replacement.md Use the Masking attribute to define the masking rule for a field. ```php #[Transformer\Masking(PartialEnum::NAME)] ``` -------------------------------- ### Apply a Transformer Attribute to a Property Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/attributes.md Use the Transformer namespace to apply masking attributes to Doctrine-mapped properties. ```php use TacticMedia\GreenmaskBundle\Attribute\Transformer; use TacticMedia\GreenmaskBundle\Attribute\Transformer\PartialEnum; #[ORM\Column(name: 'display_name')] #[Transformer\Masking(PartialEnum::NAME)] private string $displayName; ``` -------------------------------- ### Declare Anonymisation Rules on Doctrine Entities Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/README.md Use PHP attributes to define masking and transformation rules directly on entity properties. ```php use Doctrine\ORM\Mapping as ORM; use TacticMedia\GreenmaskBundle\Attribute\Transformer; use TacticMedia\GreenmaskBundle\Attribute\Transformer\PartialEnum; #[ORM\Entity] #[ORM\Table(name: 'user', schema: 'core')] class User { #[ORM\Column(name: 'display_name')] #[Transformer\Masking(PartialEnum::NAME)] private string $displayName; #[ORM\Column] #[Transformer\RandomEmail(preserve: ['admin@example.com'], domains: ['disabled.localhost'])] private string $email; } ``` -------------------------------- ### Json Transformer Source: https://github.com/tacticmedia/greenmask-bundle/blob/main/docs/transformers/advanced.md The Json transformer edits json or jsonb documents at specified paths using set or delete operations. ```APIDOC ## Json Transformer ### Description Edits a json or jsonb document at named paths, leaving the rest of the document unchanged. ### Parameters - **operations** (non-empty-list) - Required - A list of operations to perform on the JSON document. - **keep_null** (bool) - Optional - Whether to keep null values. - **when** (string) - Optional - Conditional logic for the transformer. ### Operation Fields - **operation** (string) - Required - Either 'set' or 'delete'. - **path** (string) - Required - A gjson path into the document. - **value** (mixed) - Optional - The literal value to write. - **value_template** (string) - Optional - A Go template whose output is written. - **error_not_exist** (bool) - Optional - Fail when the path is missing. - **skip_not_exist** (bool) - Optional - Leave the document alone when the path is missing. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.