Skip to content
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

CRLF Verification Handler enablement #30029

Open
wants to merge 1 commit into
base: netty-transport-http
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

public class CRLFValidationHandler extends ChannelInboundHandlerAdapter {

private static final int MAX_CRLF_ALLOWED = 0;
private static final int MAX_CRLF_ALLOWED = 2;

@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ private void setupHttp11Pipeline(ChannelPipeline pipeline) {

//TODO: check for best default first line max size (changing for jwt test)
HttpServerCodec sourceCodec = new HttpServerCodec(8192, Integer.MAX_VALUE, httpConfig.getIncomingBodyBufferSize());
//pipeline.addLast(CRLF_VALIDATION_HANDLER, new CRLFValidationHandler());
pipeline.addLast(CRLF_VALIDATION_HANDLER, new CRLFValidationHandler());
pipeline.addLast(NETTY_HTTP_SERVER_CODEC, sourceCodec);
pipeline.addLast(HTTP_DISPATCHER_HANDLER_NAME, new HttpDispatcherHandler(httpConfig));
addPreHttpCodecHandlers(pipeline);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected void configurePipeline(ChannelHandlerContext ctx, String protocol) thr
}
ctx.pipeline().addAfter(HttpPipelineInitializer.HTTP_ALPN_HANDLER_NAME, HttpPipelineInitializer.NETTY_HTTP_SERVER_CODEC,
new HttpServerCodec(8192, Integer.MAX_VALUE, httpConfig.getIncomingBodyBufferSize()));
// ctx.pipeline().addBefore(HttpPipelineInitializer.NETTY_HTTP_SERVER_CODEC, HttpPipelineInitializer.CRLF_VALIDATION_HANDLER, new CRLFValidationHandler());
ctx.pipeline().addBefore(HttpPipelineInitializer.NETTY_HTTP_SERVER_CODEC, HttpPipelineInitializer.CRLF_VALIDATION_HANDLER, new CRLFValidationHandler());
ctx.pipeline().addAfter(HttpPipelineInitializer.NETTY_HTTP_SERVER_CODEC, HttpPipelineInitializer.HTTP_KEEP_ALIVE_HANDLER_NAME, new HttpServerKeepAliveHandler());
//TODO: this is a very large number, check best practice
ctx.pipeline().addAfter(HttpPipelineInitializer.HTTP_KEEP_ALIVE_HANDLER_NAME, HttpPipelineInitializer.HTTP_AGGREGATOR_HANDLER_NAME,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2023 IBM Corporation and others.
* Copyright (c) 2023, 2024 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -117,11 +117,11 @@ public void exceptionCaught(ChannelHandlerContext context, Throwable cause) thro
return;
} else if (cause instanceof IllegalArgumentException) {
//Legacy doesnt throw ffdc on processNewInformation
//if(context.channel().attr(NettyHttpConstants.THROW_FFDC).get() != null){
// context.channel().attr(NettyHttpConstants.THROW_FFDC).set(null);
//}else{
if(context.channel().attr(NettyHttpConstants.THROW_FFDC).get() != null){
context.channel().attr(NettyHttpConstants.THROW_FFDC).set(null);
}else{
FFDCFilter.processException(cause, HttpDispatcherHandler.class.getName() + ".exceptionCaught(ChannelHandlerContext, Throwable)", "1", context);
//}
}

if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "exceptionCaught encountered an IllegalArgumentException : " + cause);
Expand Down