Files
monolog-gdpr-filter/src/MaskConstants.php
Ismo Vuorinen 00c6f76c97 feat: performance, integrations, advanced features (#2)
* feat: performance, integrations, advanced features

* chore: fix linting problems

* chore: suppressions and linting

* chore(lint): pre-commit linting, fixes

* feat: comprehensive input validation, security hardening, and regression testing

- Add extensive input validation throughout codebase with proper error handling
- Implement comprehensive security hardening with ReDoS protection and bounds checking
- Add 3 new regression test suites covering critical bugs, security, and validation scenarios
- Enhance rate limiting with memory management and configurable cleanup intervals
- Update configuration security settings and improve Laravel integration
- Fix TODO.md timestamps to reflect actual development timeline
- Strengthen static analysis configuration and improve code quality standards

* feat: configure static analysis tools and enhance development workflow

- Complete configuration of Psalm, PHPStan, and Rector for harmonious static analysis.
- Fix invalid configurations and tool conflicts that prevented proper code quality analysis.
- Add comprehensive safe analysis script with interactive workflow, backup/restore
  capabilities, and dry-run modes. Update documentation with linting policy
  requiring issue resolution over suppression.
- Clean completed items from TODO to focus on actionable improvements.
- All static analysis tools now work together seamlessly to provide
  code quality insights without breaking existing functionality.

* fix(test): update Invalid regex pattern expectation

* chore: phpstan, psalm fixes

* chore: phpstan, psalm fixes, more tests

* chore: tooling tweaks, cleanup

* chore: tweaks to get the tests pass

* fix(lint): rector config tweaks and successful run

* feat: refactoring, more tests, fixes, cleanup

* chore: deduplication, use constants

* chore: psalm fixes

* chore: ignore phpstan deliberate errors in tests

* chore: improve codebase, deduplicate code

* fix: lint

* chore: deduplication, codebase simplification, sonarqube fixes

* fix: resolve SonarQube reliability rating issues

Fix useless object instantiation warnings in test files by assigning
instantiated objects to variables. This resolves the SonarQube reliability
rating issue (was C, now targeting A).

Changes:
- tests/Strategies/MaskingStrategiesTest.php: Fix 3 instances
- tests/Strategies/FieldPathMaskingStrategyTest.php: Fix 1 instance

The tests use expectException() to verify that constructors throw
exceptions for invalid input. SonarQube flagged standalone `new`
statements as useless. Fixed by assigning to variables with explicit
unset() and fail() calls.

All tests pass (623/623) and static analysis tools pass.

* fix: resolve more SonarQube detected issues

* fix: resolve psalm detected issues

* fix: resolve more SonarQube detected issues

* fix: resolve psalm detected issues

* fix: duplications

* fix: resolve SonarQube reliability rating issues

* fix: resolve psalm and phpstan detected issues
2025-10-31 13:59:01 +02:00

91 lines
3.1 KiB
PHP

<?php
declare(strict_types=1);
namespace Ivuorinen\MonologGdprFilter;
/**
* Constants for mask replacement values.
*
* This class provides standardized mask values to avoid duplication
* and ensure consistency across the codebase.
*/
final class MaskConstants
{
// Data type masks
public const MASK_INT = '***INT***';
public const MASK_FLOAT = '***FLOAT***';
public const MASK_STRING = '***STRING***';
public const MASK_BOOL = '***BOOL***';
public const MASK_NULL = '***NULL***';
public const MASK_ARRAY = '***ARRAY***';
public const MASK_OBJECT = '***OBJECT***';
public const MASK_RESOURCE = '***RESOURCE***';
// Generic masks
public const MASK_GENERIC = '***'; // Simple generic mask
public const MASK_MASKED = '***MASKED***';
public const MASK_REDACTED = '***REDACTED***';
public const MASK_FILTERED = '***FILTERED***';
public const MASK_BRACKETS = '[MASKED]';
// Personal identifiers
public const MASK_HETU = '***HETU***'; // Finnish SSN
public const MASK_SSN = '***SSN***'; // Generic SSN
public const MASK_USSSN = '***USSSN***'; // US SSN
public const MASK_UKNI = '***UKNI***'; // UK National Insurance
public const MASK_CASIN = '***CASIN***'; // Canadian SIN
public const MASK_PASSPORT = '***PASSPORT***';
// Financial information
public const MASK_IBAN = '***IBAN***';
public const MASK_CC = '***CC***'; // Credit Card
public const MASK_CARD = '***CARD***'; // Credit Card (alternative)
public const MASK_UKBANK = '***UKBANK***';
public const MASK_CABANK = '***CABANK***';
// Contact information
public const MASK_EMAIL = '***EMAIL***';
public const MASK_PHONE = '***PHONE***';
public const MASK_IP = '***IP***';
// Security tokens and keys
public const MASK_TOKEN = '***TOKEN***';
public const MASK_APIKEY = '***APIKEY***';
public const MASK_SECRET = '***SECRET***';
// Personal data
public const MASK_DOB = '***DOB***'; // Date of Birth
public const MASK_MAC = '***MAC***'; // MAC Address
// Vehicle and identification
public const MASK_VEHICLE = '***VEHICLE***';
// Healthcare
public const MASK_MEDICARE = '***MEDICARE***';
public const MASK_EHIC = '***EHIC***'; // European Health Insurance Card
// Custom/Internal
public const MASK_INTERNAL = '***INTERNAL***';
public const MASK_CUSTOMER = '***CUSTOMER***';
public const MASK_NUMBER = '***NUMBER***';
public const MASK_ITEM = '***ITEM***';
// Custom mask patterns for partial masking
public const MASK_SSN_PATTERN = '***-**-****'; // SSN with format preserved
public const MASK_EMAIL_PATTERN = '***@***.***'; // Email with format preserved
// Error states
public const MASK_INVALID = '***INVALID***';
public const MASK_TOOLONG = '***TOOLONG***';
public const MASK_ERROR = '***ERROR***';
/**
* Prevent instantiation.
*
* @psalm-suppress UnusedConstructor
*/
private function __construct()
{}
}