test: add Pest v1 security test infrastructure - #131
Conversation
Add source-scan tests verifying security patterns (prepared statements, output escaping, auth guards, PHP 7.4 compatibility) remain in place across refactors. Tests run with Pest v1 (PHP 7.3+) and stub the Cacti framework so plugins can be tested in isolation. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR introduces a Pest v1-based test scaffold for the ReportIt plugin, focused on lightweight security/regression checks without requiring a full Cacti runtime.
Changes:
- Add Pest bootstrap/configuration to run tests in this repository.
- Add a setup.php structure smoke test to verify expected plugin hooks/version keys exist.
- Add source-scan tests for prepared-statement usage consistency and PHP 7.4 syntax compatibility.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| composer.json | Adds Pest v1 as a dev dependency and wires test bootstrap via autoload-dev. |
| tests/Pest.php | Pest entrypoint requiring the local test bootstrap. |
| tests/bootstrap.php | Provides Cacti function/constant stubs intended to support isolated test execution. |
| tests/Security/SetupStructureTest.php | Verifies required plugin hook functions and version keys exist in setup.php. |
| tests/Security/PreparedStatementConsistencyTest.php | Scans selected plugin files to detect raw db_* calls vs *_prepared helpers. |
| tests/Security/Php74CompatibilityTest.php | Scans selected plugin files for PHP 8+ function/syntax usage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…dabot - Throw RuntimeException when realpath/file_get_contents fails (previously silent continue hid unscanned files) - Fix Dependabot ecosystem from npm to composer - Remove committed .omc session artifacts, add .omc/ to .gitignore Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
|
Converted to draft to serialize the stack in this repo. Blocked by #128; will un-draft after that merges to avoid cross-PR merge conflicts. |
…lity Fail fast on unreadable target files instead of silently skipping them, narrow the prepared-statement scan to already-migrated files, dedupe the PHP 7.4 compatibility file-reading logic, and replace describe() (not available in Pest v1) with top-level it() blocks so the suite actually executes. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
|
Addressed review feedback on the Pest security test suite:
Note: one pre-existing assertion (SetupStructureTest's "returns version array with version key") still fails - setup.php's version info comes from the INFO ini file via parse_ini_file(), not a literal array in setup.php, so the regex doesn't match. Leaving that as-is since fixing it means deciding what the test should actually check; flagging for follow-up. |
Summary
Test plan
composer install && vendor/bin/pestpasses