Repository navigation
feat(agent): inject an AgentHandlerProtocol bean into GuardMiddleware - #18
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.
spring-boot-guard could not use the Java agent at all.
GuardMiddlewarekept its agent handler in a private field that nothing ever set, and withguard.enable-agent=trueit always degraded with "guard-agent-jvm is not available in this build yet (W7 artifact)".What changes, mirroring ktor-guard's
GuardCoreMiddleware:GuardMiddlewaretakes an optionalinjectedAgentHandler. The auto-configuration passes anyAgentHandlerProtocolbean throughObjectProvider.HandlerInitializer. Oninitialize(), the middleware adopts the engine composite as its agent handler, as pythoninitialize()does.GuardMiddleware.shutdown()stops the agent integrations. Spring calls it as the bean's inferred destroy method, so the agent flushes on context close.Tests (
GuardAgentWiringTest.kt):shutdown()stops it.@SpringBootTestwhere a registered bean receives the events of a blocked request.Against the old engine pin, the two delivery tests fail with
expected: 1 but was: 0; against 9067b7b they pass.End to end, I ran a scratch Boot app with this adapter, the real guard-agent-jvm, and the engine at the fix, against a local capture server. Three blocked and three allowed requests produced one events batch (user_agent_blocked, security_headers_applied) and one metrics batch (request_count, response_time). Both validate against guard-core-app's ingestion model (
BatchTelemetryRequest). Before the engine fix, the same run sent 0 requests.Local gate:
./gradlew buildpasses (39 tests, 0 failures) against guard-core-jvm 9067b7b. Nothing is released.