-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Add ECS compliant option for username field #54051
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
Conversation
Pinging @elastic/es-security (:Security/Security) |
@@ -93,7 +96,11 @@ public IngestDocument execute(IngestDocument ingestDocument) throws Exception { | |||
switch (property) { | |||
case USERNAME: | |||
if (user.principal() != null) { | |||
userObject.put("username", user.principal()); | |||
if (escCompliant && "user".equals(field)) { |
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 not ideal.
It means if you set
{ "field": "user", "ecs_compliant": true}
you get a name
field but for { "field": "es_user", "ecs_compliant": true}
you get a username
field. That's unnecessarily confusing .
My gut-feel preference would be that ecsCompliant
mode requires that the field be named "user"
.
{ "field": "auth", "ecs_compliant": true}
should fail as an invalid configuration.
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.
You are right. It is very confusing. The option is effectively just a "hint". I think tighten the behaviour as you suggested makes sense. Will update. Thanks
...security/src/main/java/org/elasticsearch/xpack/security/ingest/SetSecurityUserProcessor.java
Outdated
Show resolved
Hide resolved
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.
Generally speaking I would abstain from introducing the ecs_compliant
configuration option. I believe it's "unatractive" as there's some overhead to learn what it means. I would approach the transition to ECS by simply naming the field differently, eg name
instead of username
, and having a default value for the field
property as user
.
In addition, I think we should be mindful that there could be several "users" in an ingest document, so I would follow the recommendation from https://www.elastic.co/guide/en/ecs/current/ecs-user.html#_field_reuse_19 and have a nested user
object under a configurable field
.
So, to summarize, in 7.x I would simply add a new property name
with the same value as username
, and in 8 I would create a new user
object (containing the name
property) under a configurable field, for example ingest
.
@ywangd Let me know what you think of this.
@@ -93,7 +99,11 @@ public IngestDocument execute(IngestDocument ingestDocument) throws Exception { | |||
switch (property) { | |||
case USERNAME: |
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 makes it so that the user can specify the username
property when defining the pipeline, but the field is actually named name
(in 8 when ecs_compliat
is true
by default). This is mildly confusing. I would suggest that we add a new property name
with the same value as username
.
@@ -57,6 +62,7 @@ public SetSecurityUserProcessor(String tag, SecurityContext securityContext, XPa | |||
} | |||
this.field = field; | |||
this.properties = properties; | |||
this.escCompliant = ecsCompliant; |
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.
there are many places with the esc
-> ecs
inversion (including the PR title).
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.
Fixed most of them other than the one in the PR branch name. Thanks for spotting this.
@@ -193,6 +207,7 @@ public Factory(Supplier<SecurityContext> securityContext, Supplier<XPackLicenseS | |||
public SetSecurityUserProcessor create(Map<String, Processor.Factory> processorFactories, String tag, | |||
Map<String, Object> config) throws Exception { | |||
String field = readStringProperty(TYPE, tag, config, "field"); |
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.
Should the field have a default value of user
for 8?
@albertzaharovits My concern is about backwards compatibility for existing user data. If there is no option to opt-out of this new behaviour, users are forced to reindex their existing data for consistent data structure. This may not be what we want to tell the users? Therefore I’d like to give users the option to keep existing behaviour even in 8.0 and this is where the
Your suggestion of making a nested {
"auth": {
"user": {
"name": "...",
"full_name": "...",
"email": "...",
"roles": "...",
"metadata": {}
},
"realm": {},
"api_key": {},
"authentication_type": "..."
}
} In this case, we also need update docs to name the parent field |
Thank you for describing the
I believe the parent field is configurable and should stay that way? This new structure looks more precise, and I prefer it. What are your thoughts about this? I slightly prefer adding a new processor because I believe it's easier on the user to cope with different document structures this way and I hope we can internally reuse the code of the existing processor, but I also think that the approach you've described works well too! |
Sorry for the confusion. Yes it is and will stay configurable. What I meant was the example used in the docs page. It configures the field to be named as "user". But we will want to change it to "auth". BWC indeed needs some more thoughts here. With my proposal, there will still be a problem when user has a mixed cluster of 8.0 and 7.x. Unless users actively do something, an existing processor will be created differently in 8.0 and 7.x since they have different default for ECS compliance. Even though we can put forward upgrade instruction, the chance of user ignoring it and running into this problem is still non-negligible. In fact, even for newly created processors, they will also still be created differently in a mixed cluster ... I think the overall requirement for this change should satisfy the follows:
In light of above discussion, I think creating a seperate processor is reasonable. It could potential duplicate quite a bit code and docs but solves the BWC problem easily and better. |
The scenario of creating ingest processors in mixed cluster is a good point! |
@tvernum Does creating a new processor make sense to you? It does feel like a "big" change given the initial perceived scope of this issue. Here is a list of pros and cons for adding a new processor: Pros
Cons
The alternative is to add a new Pros
Cons
|
To be honest, my feeling is that this probably isn't an issue we need to solve at all right now. It would be nice to have this processor create ECS compliant data, but unless someone is specifically asking for it (thinking mostly of SIEM and/or Obersability-Ingest teams), then maybe it would be better to spend our time elsewhere. For a lot of use cases, the user that ingests the document is not the most interesting user from an ECS point of view. If I ingest Elasticsearch audit logs using beats, the user in the log messages is the interesting part, not the user that runs beats. I think that's going to be true for almost all SIEM related ingestion and a lot of observability as well. That said:
|
Thanks Tim. I agree it's not a priority. By creating a new processor, the plan is to keep the old one available but deprecated in 8.0 and full removal only for 9.0. It's still quite a while to come. I'll deprioritize it for now. Having a consensus on the approach also allows us to come back to it quickly when needed. |
I am closing this as I don't see it getting picked up again anytime soon. The issue will stay open so we can always come back to it when necessary. |
Add a new option, ecs_compliant, to the SetSecurityUserProcessor configuration. When it is true, it requires the parent field is named as "user" and also save the username as a "name" child field for ECS compliance. The option defaults to true for 8.0 and will be a breaking change. It is possible to opt-out this new behaviour by explicitly set the option to be false so that existing behaviour is retained.
Resolves: #51799