refactor: safe PHP 7.4 modernization - #69
Conversation
There was a problem hiding this comment.
Pull request overview
This PR modernizes the WebSeer plugin’s PHP code style (strict typing + short arrays) and adds initial security hardening scaffolding (audit docs, URL validator, tests, and CI config).
Changes:
- Add
declare(strict_types=1);across plugin entrypoints and supporting files, and refactor manyarray()usages to[](including prepared-statement parameter arrays). - Introduce security documentation and a new
UrlValidatorseam plus a new security-focused test file. - Add CI/static-analysis config (GitHub Actions, PHPUnit config, PHPStan config, Infection config).
Reviewed changes
Copilot reviewed 30 out of 30 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| webseer.php | Adds strict types; converts prepared-statement params and arrays to short syntax |
| webseer_servers.php | Adds strict types; converts prepared-statement params and arrays to short syntax |
| webseer_proxies.php | Adds strict types; converts arrays to short syntax |
| webseer_process.php | Adds strict types; converts prepared-statement params/arrays to short syntax |
| setup.php | Adds strict types; converts arrays/prepared-statement params to short syntax |
| poller_webseer.php | Adds strict types; converts prepared-statement params/arrays to short syntax |
| remote.php | Adds strict types; converts some arrays to short syntax; touches remote actions |
| includes/functions.php | Adds strict types; converts arrays to short syntax; touches remote-sync helpers |
| includes/arrays.php | Adds strict types; converts config/field definition arrays to short syntax |
| includes/constants.php | Adds strict types |
| includes/index.php | Adds strict types |
| index.php | Adds strict types |
| classes/cURL.php | Adds strict types; refactors some arrays and signature defaults |
| classes/mxlookup.php | Adds strict types; converts arrays to short syntax in class internals |
| classes/index.php | Adds strict types |
| images/index.php | Adds strict types |
| locales/index.php | Adds strict types |
| locales/po/index.php | Adds strict types |
| locales/LC_MESSAGES/index.php | Adds strict types |
| src/Security/UrlValidator.php | Adds SSRF-oriented URL validation helper + shim function |
| tests/Security/SsrfTest.php | Adds security regression/spec tests (Pest-style) |
| phpunit.xml | Adds PHPUnit configuration |
| phpstan.neon | Adds PHPStan configuration |
| infection.json | Adds Infection mutation-testing configuration |
| .github/workflows/ci.yml | Adds GitHub Actions workflow to run tests + PHPStan |
| SECURITY.md | Adds vulnerability disclosure policy |
| SECURITY-AUDIT.md | Adds detailed security audit findings and remediation notes |
| BACKLOG.md | Adds security hardening backlog and acceptance criteria |
| .omc/state/subagent-tracking.json | Adds tool state artifact (appears non-source) |
| .omc/state/checkpoints/checkpoint-2026-03-10T08-14-41-766Z.json | Adds tool checkpoint artifact (appears non-source) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
a6dd110 to
d45bbaa
Compare
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
- Use inet_pton() to normalize IPv6 before checking loopback/link-local/ULA - Catch expanded notation like 0:0:0:0:0:0:0:1 as loopback - Detect IPv4-mapped IPv6 (::ffff:a.b.c.d) and check the inner v4 address - Resolve both A and AAAA records via dns_get_record so IPv6-only hosts aren't blocked as 'unresolvable' - Split IPv4/IPv6 internal checks into dedicated helpers 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 #65; will un-draft after that merges to avoid cross-PR merge conflicts. |
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
|
Closing in favor of #65, which carries the PHP 7.4 idiom work for these files without the overlap. This branch also picked up build artifacts that shouldn't ship (.omc/state, BACKLOG.md, SECURITY-AUDIT.md, infection.json), and its src/Security/UrlValidator.php isn't wired into any call path. Consolidating the webseer hardening into fewer PRs so review isn't split across seven branches. |
This PR adds strict typing, short array syntax, and null coalescing operators across the plugin. Standalone infrastructure files were removed per architectural mandate.