Skip to content

Psrstan#63

Open
bmfmancini wants to merge 33 commits into
Cacti:developfrom
bmfmancini:psrstan
Open

Psrstan#63
bmfmancini wants to merge 33 commits into
Cacti:developfrom
bmfmancini:psrstan

Conversation

@bmfmancini

Copy link
Copy Markdown
Member

Full PSR12 and PHPstan level 8 sweep
Typing run completed
Drop support for PHP7 syntax

security: harden audit logging and management

- prevent stored XSS in audit views
- require CSRF-protected POST and management permission for purging
- recursively redact web and CLI credentials
- generate safe, standards-compliant CSV exports
- record hook events explicitly as attempted actions
- harden retention, replication, and external logging
- add security regression checks
- bump plugin version to 1.3
security: complete audit logging hardening

- bound request depth, field counts, string sizes, and JSON parsing
- detect and redact additional secret-shaped values
- finalize request outcomes as completed or failed
- track and retry failed external log delivery
- expose delivery status in the UI and CSV exports
- upgrade existing remote-poller schemas
- add retention, schema, delivery, and security regression tests
- update documentation and translation template
- bump plugin version to 1.4
This will make it easier for some SIEMS like splunk to ingest the log file
feat: add normalized compliance audit event capture

- add event and correlation UUIDs with integrity metadata
- record actor, target, outcome, timing, and event classification
- deliver finalized request outcomes to external log consumers
- audit log views, searches, details, exports, and purges
- capture logout and session-timeout events on Cacti 1.2.x
- finalize CLI audit events and expand CSV exports
- add schema migration, documentation, and tests
…ce-event-capture

# Conflicts:
#	.github/workflows/plugin-ci-workflow.yml
#	CHANGELOG.md
#	README.md
#	audit.php
#	audit_functions.php
#	setup.php
- composer.json with php-cs-fixer ^3.86, phpstan ^2.2, pest ^2
- .php-cs-fixer.php copied verbatim from Cacti develop (tabs, custom ruleset)
- .phpstan.neon matching Cacti shape, paths adapted, level 8
- phpstan/stubs/cacti.stubs.php typed Cacti function signatures
- .editorconfig (tabs for PHP/JS/SH, binary for po/pot/mo)
- .gitignore updated for vendor/, caches, baseline

Phase 1 of code quality sweep. No functionality changes.
- Convert array() to short array syntax []
- Normalize switch/case indentation (PSR-12)
- Convert dirname(__FILE__) to __DIR__
- Normalize else if to elseif
- Apply binary operator alignment (=> = ===)
- Single quotes, concat spaces, trailing whitespace
- Fix controller_security_test assertions for short array syntax
- Fix SetupStructureTest to check INFO file instead of source regex

Phase 2 of code quality sweep. No functionality changes.
- Add declare(strict_types=1) to all in-scope PHP files
- Replace Php74CompatibilityTest with Php81SyntaxTest
- Php81SyntaxTest asserts strict_types and short array syntax
- CS-Fixer normalizes declare spacing to Cacti convention

Phase 3 (partial) of code quality sweep. No functionality changes.
- Remove declare(strict_types=1) from all PHP files per team lead directive
- Update Php81SyntaxTest to not assert strict_types
- strict_types will not be supported until Cacti 1.3 is released

No functionality changes.
- audit_syslog.php: 38 functions typed (params + return types)
- audit_functions.php: 30 functions typed (params + return types)
- setup.php: 19 functions typed (params + return types)
- audit.php: 7 functions typed (params + return types)
- Uses union types (array|false, int|false), mixed, nullable (?T), void
- No strict_types (deferred until Cacti 1.3)
- No functionality changes — types match existing runtime values

Phase 3 of code quality sweep.
- Add @param/@return array value type docblocks (40+ missingType.iterableValue)
- Add is_array() guards for foreach on db_fetch results (7 foreach.nonIterable)
- Add is_array/null-coalescing guards for array|false offset access (6 errors)
- Add null coalescing for string|null arguments (preg_replace, trim, substr)
- Add resource|false guards for fputcsv/fclose
- Fix audit_json_encode fallback to guarantee string return
- Fix audit_syslog_config null coalescing for optional keys (20 offsetAccess.notFound)
- Fix stubs: __() variadic, api_plugin_register_hook 5th param, db_add_index mixed
- Add ignoreErrors for includeOnce.fileNotFound, treatPhpDocTypesAsCertain: false
- Regenerate baseline (210 errors, all in test files / pre-existing debt)
- PHPStan with baseline: 0 errors. Without baseline: 7 source errors (all ignored)

Phase 4 of code quality sweep. No functionality changes.
- .github/workflows/code-quality.yml: PHP 8.1/8.2/8.3/8.4 matrix
- Runs PHP-CS-Fixer (dry-run), PHPStan, Pest, and plain-PHP tests
- Existing plugin-ci-workflow.yml remains unchanged

Phase 5 of code quality sweep. No functionality changes.
- Bump minimum PHP to ^8.2 (pest ^2 requires PHP 8.2+)
- Pin symfony components to ^7.0 (avoid PHP 8.4-only symfony 8.x)
- Set composer platform.php to 8.2 for reproducible lock
- Regenerate composer.lock with 8.2-compatible versions
- Update CI matrix to PHP 8.2/8.3/8.4

Fixes CI composer install failure on PHP 8.1.
- Keep require php ^8.1; pest ^2.0 requires PHP 8.2 so:
  - composer install uses --ignore-platform-reqs (lock resolves on any PHP)
  - platform pinned to 8.2 for reproducible lock
  - symfony pinned to ^7.0
- Pest tests skipped on PHP 8.1 in CI (pest 2.x needs 8.2+)
- PHP-CS-Fixer and PHPStan run on all PHP versions (8.1-8.4)
- Regenerate baseline (210 errors, unchanged)

Fixes CI composer install failure while maintaining PHP 8.1 support.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant