diff --git a/README.md b/README.md index 7f83770..6fd4c54 100644 --- a/README.md +++ b/README.md @@ -135,19 +135,28 @@ When integrated with Monolog and CloudWatch, logs are automatically sent to Clou ### Sensitive Field Masking -By default, the following sensitive fields have their values masked in logs: +The module provides configurable masking of sensitive field values in entity change logs. When sensitive fields are modified, they appear in logs with masked values (e.g., `***MASKED***`) instead of actual values, providing an audit trail while protecting sensitive data. + +#### Default Sensitive Fields + +By default, the following field has its value masked: - `pass` - User passwords -- `uuid` - Entity UUIDs -- `revision_timestamp` - Revision timestamps -- `revision_uid` - Revision authors -- `revision_log` - Revision log messages -- `changed` - Changed timestamps -When these fields are modified, they appear in the logs with masked values (e.g., `***MASKED***`) instead of actual values, providing an audit trail while protecting sensitive data. +#### Configuring Sensitive Fields + +You can customize which fields are masked through the administrative interface: + +1. Navigate to **Configuration** > **Development** > **Logging and errors** (`/admin/config/development/logging`) +2. Click on the **UCEAP Logging** tab +3. Enter field machine names (one per line) in the "Sensitive Fields" textarea +4. Click "Save configuration" -Additionally, computed and internal fields are automatically excluded from logging as they are derived values. +#### Automatically Excluded Fields -To customize which fields are masked, modify the `$sensitive_fields` array in `_uceap_logging_get_entity_field_changes()`. +In addition to user-configured sensitive fields, the following field types are automatically excluded from change tracking entirely: +- Computed fields (derived values) +- Internal fields (system-managed) +- Specific metadata fields: `changed`, `revision_timestamp`, `revision_uid`, `revision_log` ### Logger Channels diff --git a/config/install/uceap_logging.settings.yml b/config/install/uceap_logging.settings.yml new file mode 100644 index 0000000..8f412ae --- /dev/null +++ b/config/install/uceap_logging.settings.yml @@ -0,0 +1,2 @@ +sensitive_fields: + - pass diff --git a/config/schema/uceap_logging.schema.yml b/config/schema/uceap_logging.schema.yml new file mode 100644 index 0000000..5d8b974 --- /dev/null +++ b/config/schema/uceap_logging.schema.yml @@ -0,0 +1,10 @@ +uceap_logging.settings: + type: config_object + label: 'UCEAP Logging Settings' + mapping: + sensitive_fields: + type: sequence + label: 'Sensitive fields' + sequence: + type: string + label: 'Field name' diff --git a/src/Form/LoggingSettingsForm.php b/src/Form/LoggingSettingsForm.php new file mode 100644 index 0000000..f3de946 --- /dev/null +++ b/src/Form/LoggingSettingsForm.php @@ -0,0 +1,82 @@ +config('uceap_logging.settings'); + + $form['sensitive_fields'] = [ + '#type' => 'textarea', + '#title' => $this->t('Sensitive Fields'), + '#description' => $this->t('Enter field machine names (one per line) that should have their values masked in entity change logs. When these fields are modified, they will appear in logs with masked values (e.g., ***MASKED***) instead of actual values.'), + '#default_value' => implode("\n", $config->get('sensitive_fields') ?? []), + '#rows' => 10, + ]; + + $form['help'] = [ + '#type' => 'details', + '#title' => $this->t('Examples'), + '#open' => FALSE, + ]; + + $form['help']['examples'] = [ + '#markup' => $this->t('
Common sensitive fields include:
+field_ssn - Social Security Numberspass - User passwordsfield_bank_account - Banking informationfield_credit_card - Payment informationfield_api_key - API keys or tokensNote: The following fields are automatically excluded from logging: changed, revision_timestamp, revision_uid, revision_log. Additionally, computed and internal fields are never logged.