-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Implement filtering mechanism in the Logging service #57547
Comments
Pinging @elastic/kibana-platform (Team:Platform) |
|
I strongly prefer we just filter the sensitive data out but still log the message. |
LP relies on Hapi log output for request/response and filters data in JSON before formatting them. We will control the output format for
The current implementation allows only 2 operations:
|
A few initial thoughts:
As @restrry outlines above, legacy platform isn't providing too much for us here: with the current filters config, we can basically just remove a property, or censor via regex. The concept of filters in log4j actually sounds a bit different from the way we've used "filters" in LP logging; they basically serve to determine whether a log entry should be included in its entirety, or thrown out:
However, AFAICT what you can't do with log4j filters alone is modify existing log messages. For that they provide a RewriteAppender, which is sort of a proxy appender that modifies a log entry based on configuration before passing it to a "destination" appender. RewriteAppenders and Filters do have some overlap (you can optionally provide a Filter in a RewriteAppender configuration), but if our primary goal is feature parity with LP, I don't think we necessarily need to introduce the concept of Filters at all -- that feels like an entirely different feature. Rather, we'd need to create our own RewriteAppender. This would let us continue to do things like "censoring" a log message by redacting particular headers, performing string replacements in a log message, adding new data to a message, or upgrading/downgrading a log's level. I think the main question would be how to make the config for this as simple as possible. The logic for the actions that can be performed by a RewriteAppender reside in a RewritePolicy. In our case, it seems some type of "MetaRewritePolicy" may be all we need at first. The config could potentially look something like this: logging:
appenders:
file:
kind: file
path: ./kibana.log
layout:
kind: json
censor:
kind: rewrite
appenders: [file] # the destination appender where this is sent after modification
policy:
kind: meta # name of the policy
mode: update # or "add" or "remove" etc
# Need to think about naming here. log4j calls this KeyValuePair,
# but in some cases ("remove") you may not need a value.
property:
key: "headers.authorization" # path within the log meta object
value: "[redacted]"
root:
appenders: [censor, default]
level: debug The legacy approach seems simpler from a configuration standpoint, but is also less powerful and of course not as aligned with log4j 2. Would be interested to get some feedback on what feels like a logical first step to take. cc @restrry @joshdover @pgayvallet |
In terms of keeping this in line with log4j, I think a rewrite appender makes sense 👍 To simplify things a bit, we could omit the
That way multiple properties could be on the same policy, and we could still easily support just That said, I'm wondering if we need to support a configurable interface at all. We don't currently document the |
Yeah this would certainly save some effort, although my takeaway from the discussion in #13241 was that we still want to provide the ability to do this. FWIW I don't think it would be enormous task to create the simplest iteration of a rewrite appender as you describe above (with a policy that will only change properties in the meta). However if we don't need that functionality at all, we can easily just exclude the authorization/cookie headers in the course of #13241. |
Probably we can implement this but keep it private as an escape hatch for debug purposes #13241 (comment)?
How would you add |
One option could be to remove properties if logging:
appenders:
censor:
kind: rewrite
appenders: [file] # the destination appender where this is sent after modification
policy:
kind: meta # name of the policy
properties:
- key: "headers.authorization" # path within the log meta object
value: "[redacted]"
- key: "headers.cookie"
value: null # removes this property entirely |
To follow up on this: the cloud team has confirmed that the So if we decided not to address this at all and simply exclude Alternatively we could implement WDYT @restrry @joshdover? Have we seen any examples where having access to these headers would be useful from a debugging/support perspective? |
@lukeelmers Security team might need it to debug problems with login. I'd suggest you timebox |
This will be closed by #91492 with one important caveat: All http response logs will redact If we decide to pick up #92082 as a future enhancement, we'll be able to lift this restriction at that time and folks will be able to explicitly disable the censoring of those headers should they choose to do so. With the exception of the 3 headers listed above, the new appender will allow users to remove & modify any path in the |
Blocker for #13241
Once we move request/response logging to the new platform, we need to provide a way to censor sensitive data in the logs (e.g.
authorization
orcookie
headers).Evaluate how much work it would be to support a filtering mechanism compatible with elasticsearch logging settings https://logging.apache.org/log4j/2.x/manual/filters.html
The text was updated successfully, but these errors were encountered: