Repository navigation
feat: add Tier 1/2 security, transport timeout, and DX enhancements - #636
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Implements backwards-compatible security hardening, transport configurability, and developer experience (DX) enhancements across
src/,examples/,tests/,composer.json, andAGENTS.md.What's Changed
1. Core Security & Type Hardening (
src/)#[\SensitiveParameter]to$secretinReCaptcha::__construct()andRequestParameters::__construct()to prevent secret key exposure in PHP stack traces and error logs.Response::fromJson()to filtererror-codesarrays usingarray_values(array_filter(..., 'is_string'))rather than relying on PHPDoc type overrides.2. Additive Developer Experience & Transport Configurability (
src/)int $timeout = 60constructor parameter toCurlPost,Post, andSocketPostso callers can customize request latency budgets while preserving the 60-second default.CurlPost: SetCURLOPT_CONNECTTIMEOUT => $this->timeoutalongsideCURLOPT_TIMEOUT => $this->timeoutinCurlPost::submit().SocketPost: Added$limit = 2topreg_split()inSocketPost::submit().JsonSerializableSupport: Implemented\JsonSerializable(jsonSerialize(): array) onResponse.ReCaptcha::SITE_VERIFY_URL_ALTERNATIVE(https://www.recaptcha.net/recaptcha/api/siteverify).3. Example Security & Cleanup (
examples/)examples/recaptcha-v3-verify.phpto validate$_GET/$_SERVERsuperglobals and verify$actionagainst an explicit server-side allowlist rather than trusting arbitrary client-provided$_GET['action']values..innerHTMLwith.textContentand addedencodeURIComponent(token)inexamples/recaptcha-v3-request-scores.phpandexamples/recaptcha-content-security-policy.php.UA-123057962-1) tags fromexamples/recaptcha-request-*.php.4. Packaging, Documentation & Unit Tests (
composer.json,AGENTS.md,tests/)suggest(ext-curl,ext-openssl) tocomposer.json.AGENTS.mdrelease checklist (public const VERSIONandcomposer audit).'Y-m-d\TH:i:s\Z') inReCaptchaTestand added unit tests maintaining 100% class, method, and line coverage (75 tests, 214 assertions) and passingroave/backward-compatibility-check.