Expand appsec integrations to Laminas Framework#3716
Expand appsec integrations to Laminas Framework#3716estringana wants to merge 25 commits intomasterfrom
Conversation
820057d to
eae5325
Compare
|
✨ Fix all issues with BitsAI or with Cursor
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3716 +/- ##
==========================================
- Coverage 68.81% 68.74% -0.08%
==========================================
Files 166 166
Lines 19030 19030
Branches 1797 1797
==========================================
- Hits 13096 13082 -14
- Misses 5121 5135 +14
Partials 813 813
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Benchmarks [ tracer ]Benchmark execution time: 2026-04-14 15:46:16 Comparing candidate commit a35cd52 in PR branch Found 0 performance improvements and 6 performance regressions! Performance is the same for 188 metrics, 0 unstable metrics. scenario:MessagePackSerializationBench/benchMessagePackSerialization-opcache
scenario:PDOBench/benchPDOOverhead-opcache
scenario:PDOBench/benchPDOOverheadWithDBM-opcache
scenario:PHPRedisBench/benchRedisOverhead
scenario:SamplingRuleMatchingBench/benchRegexMatching1
scenario:SamplingRuleMatchingBench/benchRegexMatching3
|
Snapshots difference summaryThe following differences have been observed in committed snapshots. It is meant to help the reviewer. If you need to update snapshots, please refer to CONTRIBUTING.md |
d2866e8 to
651e235
Compare
c199b10 to
9b662b3
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 140b8c4617
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| $adapter = $hook->args[0] ?? null; | ||
| $userLogin = null; | ||
|
|
||
| if ($adapter && method_exists($adapter, 'getIdentity')) { | ||
| $userLogin = $adapter->getIdentity(); |
There was a problem hiding this comment.
Derive login from configured adapter on auth failures
The failure path only inspects $hook->args[0] for the adapter, so applications that use setAdapter($adapter) followed by authenticate() (no argument) emit login-failure events without a user identifier. That drops automated identification data for a common Laminas authentication flow and makes failure telemetry much less useful.
Useful? React with 👍 / 👎.
| if ($event->getRouteMatch() === null) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
Register endpoints even when route match is null
Endpoint collection is gated on getRouteMatch() !== null, so requests that route to 404/no-match paths skip collection entirely. If early traffic is mostly unmatched (or an app primarily serves unmatched probes), are_endpoints_collected() can remain false and endpoints may never be registered despite the router being available.
Useful? React with 👍 / 👎.
| if ($route instanceof \Laminas\Router\Http\Part) { | ||
| $base = self::partRouteBaseTemplate($route); | ||
| $base = $base ?? ''; | ||
| if (!$hasChild) { | ||
| return $base !== '' ? $base : null; | ||
| } | ||
| $child = self::httpRouteTemplateFromNamedRouteStack($route, $segments[1]); | ||
| if ($child === null) { | ||
| return $base !== '' ? $base : null; | ||
| } | ||
|
|
||
| return $base . $child; | ||
| } | ||
|
|
||
| if ($route instanceof \Laminas\Router\Http\TreeRouteStack && $hasChild) { | ||
| return self::httpRouteTemplateFromNamedRouteStack($route, $segments[1]); | ||
| } | ||
|
|
||
| if ($hasChild) { | ||
| return self::httpRouteTemplateFromMatchedRoute($route, null); | ||
| } |
There was a problem hiding this comment.
Wouldn't this cause the route name to be set multiple times? For the individual parts and for the high level router? I think you should not call this method unless it's the top level.
| return $out; | ||
| } | ||
|
|
||
| private static function walkRouteStackCollectEndpointRows( |
There was a problem hiding this comment.
Part children are only populated on first match(). The onRoute hook fires after one path through the route tree is matched, so only the subtree along the matched path is materialized. You need to force this materialization.
See the in the other comment when I added extra routes with child routes. Those are not found by the Endpoints are sent test.
979e638 to
b6e2fdc
Compare
Add AAP support to Laminas framework
This PR introduces AAP support to the Laminas framework, enabling improved observability and authentication-related event tracking.
Features added
Provide
http.routeCaptures and exposes the resolved route for incoming requests.
Collect endpoints at startup
Gathers and registers available endpoints during application bootstrap.
Login success event
Emits an event when a user successfully authenticates.
Login failure event
Emits an event when authentication fails.
Authenticated request events
Tracks requests performed by authenticated users.
Collect path parameters
Extracts and includes route path parameters in the collected data.
Limitations / Missing features
Not implemented because Laminas does not provide a built-in signup mechanism. This functionality is application-specific and must be implemented by developers if needed.
Reviewer checklist