-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #11253 - Cleanup ComplianceViolation behavior to allow Cookie / URI / MultiPart compliance to also receive listener events. #11254
Conversation
… URI / MultiPart compliance to also receive listener events.
Need to handle MultiPartParser (core) for ComplianceViolation too. |
I'm just going to write down some stream of consciousness thoughts about this: First principle is that we really do not want any cost to this mechanism for the 99.99% of requests without violations, nor the 99.99% of deployments that don't care even if there are. We are talking about the 0.01*0.01 = 0.0001% of users here! Thus we should not incur ANY expense unless: a) there is a violation; and b) there is a violation listener. There are two distinct use-cases that we are trying to support:
So this strikes me as we are implementing two mechanisms when we only should have one. Ideally if a deployment wants a list of violations to be made available via a request attribute, then they should be able to write a listener that adds any violation to a list obtained as an attribute. However, there are two problems with this: I) the Ignoring the 2. use-case for now, we could simplify the 1. reporting of violations by adding a However, it would not allow a deployment to create a list of violations associated with a request because the request context of a violation is not known to such a listener. So we need to think of a way to extend this, so such a behaviour can be added. Can we add some concept of scope to the violation listener API, and if so, then what is the exact lifecycle of that? It can't be request attributes, as they are only created once the request is created. We could perhaps move the request attributes to be at the scope of the I think the solution might be that a deployment that wishes to keep a list of violations will need to use the HttpChannel.Factory mechanism to return a specialized @joakime would the client be content with a mechanism that requires the connectors to be extended to add such a factory? Eitherway, I think we should first start off by making a single solution for use-case 1. that reports violations via a single pathway (probably in |
…okie-compliance-logging
…okie-compliance-logging
@gregw this PR now builds and tests green, but there are still 3 more things left to do.
This PR is growing in size, and I felt I these 3 things could easily be a new PR after this one. As for the HTTP/2 and HTTP/3 checks against HttpCompliance, check the changes in this PR to the HttpCompliance enums, theres's a few TODOs that @sbordet and I identified as possibly fitting in HTTP/2 and HTTP/3 too. |
There are a few entry points to all of this. To start with, is the configuration of this. The Connector
The Transports Each of the Transports initialize their
The Implemented ComplianceViolation.Listener classes There are 3 implemented ComplianceViolation.Listener classes in the codebase now.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is better, but I think that it becomes expensive as soon as you have a single listener, as new instances will always be created.
jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/ComplianceViolation.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/ComplianceViolation.java
Show resolved
Hide resolved
jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/ComplianceViolation.java
Show resolved
Hide resolved
jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/ComplianceViolation.java
Outdated
Show resolved
Hide resolved
...-http2-server/src/main/java/org/eclipse/jetty/http2/server/internal/HttpStreamOverHTTP2.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java
Outdated
Show resolved
Hide resolved
@gregw I just pushed a fix for the bugs you discovered. |
…cookie-compliance-logging # Conflicts: # jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/ComplianceViolation.java
@@ -321,6 +323,37 @@ public boolean isShutdownDone() | |||
LOG.info("Started {}", this); | |||
} | |||
|
|||
public ComplianceViolation.Listener getComplianceViolationListener() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going to move this entire logic to HttpConfiguration instead.
Per ideas mentioned at #11301 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be documented in the adoc documentation as well.
This PR should include that documentation update.
The porting guide might need to be updated as well.
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractConnector.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnectionFactory.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/internal/HttpConnection.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/internal/HttpConnection.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/MultiPartFormData.java
Show resolved
Hide resolved
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnectionFactory.java
Outdated
Show resolved
Hide resolved
…ging' into fix/12.0.x/cookie-compliance-logging # Conflicts: # jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Components.java # jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConfiguration.java # jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnectionFactory.java # jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/internal/HttpChannelState.java
ComplianceViolation.Listener
ComplianceViolation.Listener.initialize()
to allow for a new Listener at the appropriate time (to support per-request listeners)ComplianceViolation.CapturingListener
HttpConfiguration.(add/remove/get)ComplianceViolationListener()
methods.recordComplianceViolations
inHttpConnection
andHttpConnectionFactory
classes.ComplianceViolation.Listener
as beans is still present.ComplianceViolation.Listener
support toUriCompliance
locations.ComplianceViolation.Listener
support toMultiPartCompliance
locations.ComplianceViolation.Listener
support toCookieCompliance
locations.ComplianceViolation.Listener
support toHttpCompliance
locations in HTTP/2 and HTTP/3