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

Issue #6026 - Cleaning up warning for paths with uncovered HTTP methods #6029

Merged

Conversation

joakime
Copy link
Contributor

@joakime joakime commented Mar 3, 2021

Closes #6026

Signed-off-by: Joakim Erdfelt joakim.erdfelt@gmail.com

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
@joakime joakime self-assigned this Mar 3, 2021
@joakime joakime added this to In progress in Jetty 10.0.2/11.0.2 via automation Mar 3, 2021
}
if (LOG.isDebugEnabled())
LOG.debug("{} has uncovered http methods", currentContext, new Throwable());
LOG.warn("{} has paths with uncovered http methods: [{}]",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The log warn message is the wrong way around, it is the uncovered paths not methods, so it should be:

Suggested change
LOG.warn("{} has paths with uncovered http methods: [{}]",
LOG.warn("{} has uncovered http methods for paths: [{}]",

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yet the method name is checkPathsWithUncoveredHttpMethods ??

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, we are reporting the uncovered paths not the uncovered methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confusing.

  • "has paths with uncovered http methods" - identifies paths, that has uncovered http methods
  • "has uncovered http methods for paths" - identifies methods, that are not covered by the paths

Perhaps there's a 3rd choice that's less confusing. What does "uncovered http method" mean?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with @joakime here, the method name suggests the other way around.
Also, do we really want to use WARN? I don't think nothing happens if we hit this case, and we don't want to clog log files if repeated requests for this case happens?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of the method is "checkPathsWithUncoveredMethods" - ie we are checking the paths for which there are uncovered methods. The logging is reporting the paths, not the methods - it would be incorrect to imply that we are reporting methods!

Furthermore, this warning is required by the servlet specification: your choice if you want to make it INFO instead of WARN, but the spec requires that we produce this warning at deployment time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is the section. Please see comment by @gregw - we can enumerate the paths that are uncovered but not the methods.

Jetty 10.0.2/11.0.2 automation moved this from In progress to Review in progress Mar 5, 2021
}
if (LOG.isDebugEnabled())
LOG.debug("{} has uncovered http methods", currentContext, new Throwable());
LOG.warn("{} has paths with uncovered http methods: [{}]",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with @joakime here, the method name suggests the other way around.
Also, do we really want to use WARN? I don't think nothing happens if we hit this case, and we don't want to clog log files if repeated requests for this case happens?

@gregw
Copy link
Contributor

gregw commented Mar 9, 2021

A bit of background.... the servlet spec is beyond brain dead here!

If an app has a security constraints:

  • /foo/* with no methods specified
  • /foo/bar/* for POST methods

Then a request to /foo/bar/info with any method other than POST is not constrained at all!!!! Hence the method is uncovered.
This is a real security issue and deserves a WARNING (at the very least)! Moreover, the methods uncovered are infinite and cannot be enumerated. Only the path specifications with uncovered methods can be enumerated.

So @janbartel is correct: there should be a warning that enumerates the paths. I kind of think we should also by default refuse to deploy.... but that's also contrary to the spec and going beyond the scope of this PR to just remove a noisy stack trace... which I agree gave no needed information.

@janbartel janbartel requested a review from sbordet March 9, 2021 15:59
Copy link
Contributor

@sbordet sbordet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The boolean return value from checkPathsWithUncoveredHttpMethods() is never used, can it be changed without breaking?

LOG.debug("{} has uncovered http methods", currentContext, new Throwable());
LOG.warn("{} has paths with uncovered http methods: [{}]",
ContextHandler.getCurrentContext(),
String.join(", ", paths));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need for String.join() as Set.toString() already formats like you want (external brackets and commas to separate items).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we backport this to 9.4.x then removing the return value is a bad idea.
But for 10+ i'm fine with removing the return value.

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
@joakime
Copy link
Contributor Author

joakime commented Mar 9, 2021

Leaving it at WARN level.
Changed the message again, to be more like the original, but with better grammar.
The String.join was removed, in favor of Set.toString() instead.

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Jetty 10.0.2/11.0.2 automation moved this from Review in progress to Reviewer approved Mar 9, 2021
@joakime joakime merged commit 54dfa26 into jetty-10.0.x Mar 9, 2021
Jetty 10.0.2/11.0.2 automation moved this from Reviewer approved to Done Mar 9, 2021
@joakime joakime deleted the jetty-10.0.x-6026-cleanup-uncovered-path-warning branch March 9, 2021 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

the jvm DEBUG flag is not working org.eclipse.jetty.LEVEL=DEBUG
4 participants