Skip to content

test: add Pest v1 security test infrastructure - #131

Draft
somethingwithproof wants to merge 4 commits into
Cacti:developfrom
somethingwithproof:test/add-security-test-infrastructure
Draft

test: add Pest v1 security test infrastructure#131
somethingwithproof wants to merge 4 commits into
Cacti:developfrom
somethingwithproof:test/add-security-test-infrastructure

Conversation

@somethingwithproof

Copy link
Copy Markdown

Summary

  • Add Pest v1 test scaffold with Cacti framework stubs
  • Source-scan tests for prepared statement consistency
  • PHP 7.4 compatibility verification tests
  • Plugin setup.php structure validation

Test plan

  • composer install && vendor/bin/pest passes
  • Tests verify security patterns match hardening PRs

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>
Copilot AI review requested due to automatic review settings April 9, 2026 06:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tests/Security/SetupStructureTest.php Outdated
Comment thread tests/Security/PreparedStatementConsistencyTest.php Outdated
Comment thread tests/Security/PreparedStatementConsistencyTest.php Outdated
Comment thread tests/Security/Php74CompatibilityTest.php Outdated
…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>
@somethingwithproof
somethingwithproof marked this pull request as draft April 11, 2026 00:10
@somethingwithproof

Copy link
Copy Markdown
Author

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>
@somethingwithproof

Copy link
Copy Markdown
Author

Addressed review feedback on the Pest security test suite:

  • SetupStructureTest: fail fast with a clear error if setup.php can't be resolved/read, instead of letting a warning/TypeError obscure later assertion failures.
  • PreparedStatementConsistencyTest: fail fast on unresolvable/unreadable target files instead of silently skipping them; narrowed the file list to files that are actually fully migrated to prepared statements (lib/funct_online.php, lib/funct_reports.php, lib/funct_shared.php, and setup.php still contain raw db_execute/db_fetch_* calls, so they were dropped from this test's scope - separate from this PR).
  • Php74CompatibilityTest: extracted the repeated resolve/read logic into one helper used by all four checks, failing fast instead of silently skipping files.
  • Also fixed describe() usage across all three test files - describe() isn't available in Pest v1 (this repo's pinned version), so none of these tests could execute before this change. Replaced with top-level it() blocks.

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.

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.

2 participants