-
Notifications
You must be signed in to change notification settings - Fork 180
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
DDF-6215 Upgrade to Karaf 4.2.9 #6216
Conversation
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.
❗ FilterInjector
and DelegateServletFilter
are being used to hook in metrics to all servlets in the system using the ServletMetrics
filter. I could not find a way to get the Pax Web whiteboard to hook into all servlets in the system which is why I just fixed the injector and delegate.
https://github.com/codice/ddf/blob/master/platform/metrics/metrics-servlet-filter/src/main/java/org/codice/ddf/metrics/servlet/ServletMetrics.java
I think we could support the use case with a custom Jetty Handler
.
https://www.eclipse.org/jetty/documentation/current/jetty-handlers.html#writing-custom-handlers
The GZIP handler looks like a good example of connecting to all servlet requests and responses.
https://github.com/eclipse/jetty.project/blob/jetty-10.0.x/jetty-server/src/main/java/org/eclipse/jetty/server/handler/gzip/GzipHandler.java
https://github.com/eclipse/jetty.project/blob/jetty-10.0.x/jetty-server/src/main/config/modules/gzip.mod
https://github.com/eclipse/jetty.project/blob/jetty-10.0.x/jetty-server/src/main/config/etc/jetty-gzip.xml
StatisticsHandler
is a more direct example.
https://github.com/eclipse/jetty.project/blob/jetty-10.0.x/jetty-server/src/main/java/org/eclipse/jetty/server/handler/StatisticsHandler.java
Looks like there is even a way to register handlers directly as OSGi services which would be easier then trying to figure out how to get a mod to work with Pax Web.
http://ops4j.github.io/pax/web/SNAPSHOT/User-Guide.html#using-handler-and-connectors-as-services
...-paxweb-jettyconfig/src/main/java/org/codice/ddf/pax/web/jetty/DelegatingSecurityFilter.java
Outdated
Show resolved
Hide resolved
...-paxweb-jettyconfig/src/main/java/org/codice/ddf/pax/web/jetty/DelegatingSecurityFilter.java
Outdated
Show resolved
Hide resolved
...-paxweb-jettyconfig/src/main/java/org/codice/ddf/pax/web/jetty/DelegatingSecurityFilter.java
Outdated
Show resolved
Hide resolved
@pklinef I had the same issue trying to get a whiteboard service to hook into all servlets. Pax Web doesn't support it. That's why I ended up with the solution in this PR. Services implementing the SecurityFilter interface do get applied to all requests, so I made the I can look into the Handler suggestion, but I'm a little unclear what the issue with this solution is |
...orm-paxweb-jettyconfig/src/main/java/org/codice/ddf/pax/web/jetty/DelegateServletFilter.java
Show resolved
Hide resolved
@pklinef I looked at the I'm looking into the Jetty |
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.
* <p>When https://ops4j1.jira.com/browse/PAXWEB-1123 is resolved, this workaround should be | ||
* revisited. | ||
*/ | ||
public class DelegatingHttpFilterHandler extends HandlerWrapper { |
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.
The delegating servlet filter has a new home 😂 This time it's the Jetty Handler chain
*/ | ||
public interface HttpFilter { | ||
|
||
void doFilter( |
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.
The Jetty Handlers take HttpServletRequests. In order to inject stuff into that chain, I needed to have a filter interface that takes HttpServletRequests as well. Oddly enough this is not already a thing.
Any filters we used to inject via the delegate filter will need to be changed to implement this new interface. That will require changing the method signature and removing the init/destroy methods since those aren't used anymore.
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class ServletMetrics implements Filter { | ||
public class ServletMetrics implements HttpFilter { |
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.
Here's an example of converting an existing Filter into an HttpFilter
|
||
private HttpFilter[] getFilters() { | ||
HttpFilter[] filters = new HttpFilter[filterTracker.size()]; | ||
return filterTracker.getServices(filters); |
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 getting injected into the Jetty Handler chain via the jetty.xml config, so I couldn't just inject a service reference list like it did before. If anybody has better ideas for how to do this, I'm open to suggestions.
platform/platform-paxweb-jettyconfig/src/main/resources/OSGI-INF/blueprint/blueprint.xml
Outdated
Show resolved
Hide resolved
platform/security-filter-api/src/main/java/org/codice/ddf/platform/filter/HttpFilter.java
Outdated
Show resolved
Hide resolved
...form-paxweb-jettyconfig/src/main/java/org/codice/ddf/pax/web/jetty/ProxyHttpFilterChain.java
Show resolved
Hide resolved
...xweb-jettyconfig/src/main/java/org/codice/ddf/pax/web/jetty/DelegatingHttpFilterHandler.java
Show resolved
Hide resolved
Hero ✔️
|
build now |
Internal build has been started, your results will be available at build completion. |
Build SUCCESS See the job results in legacy Jenkins UI or in Blue Ocean UI. |
What does this PR do?
Upgrades to Karaf 4.2.9, and along with it upgrades a bunch of other dependencies to match the version that Karaf uses.
There was an attempt to upgrade previously, which ran into a number of issues (#5798). I ran into a few of the same issues for this PR. Here's the fixes:
This was a problem parsing one of the cxf feature definitions. I copied the fix from apache/cxf#602
I changed our DelegateServletFilter to be a Jetty Handler, so it doesn't need to be injected into each individual servlet context. There was no way I could find to access the servlet contexts before they were started. The handler approach accomplishes the same thing - running filters for all requests - but filters must now implement the
org.codice.ddf.platform.filter.http.HttpFilter
interface instead ofjavax.servlet.Filter
(Jetty Handlers accept HttpServletRequests instead of ServletRequests).This PR depends on: codice/thirdparty#97
Who is reviewing it?
@blen-desta @bakejeyner @garrettfreibott @stustison
Select relevant component teams:
@codice/security
How should this be tested?
Verify:
platform-paxweb-jettyconfig
bundle, you should see a bunch of messages indicating that error pages are being injected as the webapps restart. Also, produce an error in the UI (e.g. 403 by hitting /admin as guest) and verify you see the expected DDF error page.org.codice.ddf.pax.web.jetty
to TRACE and you should see a messageDelegating to 5 HttpFilters
when you make a request./metrics
and verify theddf_platform_*
metrics look realistic.Any background context you want to provide?
This is part of an ongoing effort to reduce the CVE level in DDF
What are the relevant tickets?
Fixes: #6215
Screenshots
Checklist:
Notes on Review Process
Please see Notes on Review Process for further guidance on requirements for merging and abbreviated reviews.
Review Comment Legend: