* 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
6.1 KiB
Contributing to Monolog GDPR Filter
Thank you for your interest in contributing to Monolog GDPR Filter! This document provides guidelines and information about contributing to this project.
Table of Contents
- Code of Conduct
- Getting Started
- Development Setup
- Making Changes
- Testing
- Code Quality
- Submitting Changes
- Adding New GDPR Patterns
- Security Issues
Code of Conduct
This project adheres to a code of conduct that promotes a welcoming and inclusive environment. Please be respectful in all interactions.
Getting Started
Prerequisites
- PHP 8.2 or higher
- Composer
- Git
Development Setup
-
Fork and clone the repository:
git clone https://github.com/yourusername/monolog-gdpr-filter.git cd monolog-gdpr-filter -
Install dependencies:
composer install -
Verify the setup:
composer test composer lint
Making Changes
Branch Structure
main- Stable releasesdevelop- Development branch for new features- Feature branches:
feature/description - Bug fixes:
bugfix/description - Security fixes:
security/description
Workflow
-
Create a feature branch:
git checkout -b feature/your-feature-name -
Make your changes following our coding standards
-
Test your changes:
composer test composer lint -
Commit your changes:
git commit -m "feat: add new GDPR pattern for vehicle registration"
Testing
Running Tests
# Run all tests
composer test
# Run tests with coverage (requires Xdebug)
composer test:coverage
# Run specific test file
./vendor/bin/phpunit tests/GdprProcessorTest.php
# Run specific test method
./vendor/bin/phpunit --filter testMethodName
Writing Tests
- Write tests for all new functionality
- Follow existing test patterns in the
tests/directory - Use descriptive test method names
- Include both positive and negative test cases
- Test edge cases and error conditions
Test Structure
public function testNewGdprPattern(): void
{
$processor = new GdprProcessor([
'/your-pattern/' => '***MASKED***',
]);
$result = $processor->regExpMessage('sensitive data');
$this->assertSame('***MASKED***', $result);
}
Code Quality
Coding Standards
This project follows:
- PSR-12 coding standard
- PHPStan level max for static analysis
- Psalm for additional type checking
Quality Tools
# Run all linting tools
composer lint
# Auto-fix code style issues
composer lint:fix
# Individual tools
composer lint:tool:phpcs # PHP_CodeSniffer
composer lint:tool:phpcbf # PHP Code Beautifier and Fixer
composer lint:tool:psalm # Static analysis
composer lint:tool:phpstan # Static analysis (max level)
composer lint:tool:rector # Code refactoring
Code Style Guidelines
- Use strict types:
declare(strict_types=1); - Use proper type hints for all parameters and return types
- Document all public methods with PHPDoc
- Use meaningful variable and method names
- Keep methods focused and concise
- Avoid deep nesting (max 3 levels)
Submitting Changes
Pull Request Process
-
Ensure all checks pass:
- All tests pass
- All linting checks pass
- No merge conflicts
-
Write a clear PR description:
- What changes were made
- Why the changes were necessary
- Any breaking changes
- Link to related issues
-
PR Title Format:
feat: add new featurefix: resolve bug in pattern matchingdocs: update README examplesrefactor: improve code structuretest: add missing test coverage
Commit Message Guidelines
Follow Conventional Commits:
type(scope): description
[optional body]
[optional footer(s)]
Types:
feat: New featuresfix: Bug fixesdocs: Documentation changesstyle: Code style changesrefactor: Code refactoringtest: Adding testschore: Maintenance tasks
Adding New GDPR Patterns
Pattern Guidelines
When adding new GDPR patterns to the getDefaultPatterns() method:
- Be Specific: Patterns should be specific enough to avoid false positives
- Security First: Validate patterns using the built-in
isValidRegexPattern()method - Documentation: Include clear comments explaining what the pattern matches
- Testing: Add comprehensive tests for the new pattern
Pattern Structure
// Pattern comment explaining what it matches
'/your-regex-pattern/' => '***MASKED_TYPE***',
Pattern Testing
public function testNewPattern(): void
{
$patterns = GdprProcessor::getDefaultPatterns();
$processor = new GdprProcessor($patterns);
// Test positive case
$result = $processor->regExpMessage('sensitive-data-123');
$this->assertSame('***MASKED_TYPE***', $result);
// Test negative case (should not match)
$result = $processor->regExpMessage('normal-data');
$this->assertSame('normal-data', $result);
}
Pattern Validation
Before submitting, validate your pattern:
// Test pattern safety
GdprProcessor::validatePatterns([
'/your-pattern/' => '***TEST***'
]);
// Test ReDoS resistance
$processor = new GdprProcessor(['/your-pattern/' => '***TEST***']);
$result = $processor->regExpMessage('very-long-string-to-test-performance');
Security Issues
If you discover a security vulnerability, please refer to our Security Policy for responsible disclosure procedures.
Questions and Support
- Issues: Use GitHub Issues for bug reports and feature requests
- Discussions: Use GitHub Discussions for questions and general discussion
- Documentation: Check README.md and code comments first
Recognition
Contributors are recognized in:
- Git commit history
- Release notes for significant contributions
- Special thanks for security fixes
Thank you for contributing to Monolog GDPR Filter! 🎉