-
Notifications
You must be signed in to change notification settings - Fork 164
[RORDEV-1567] ECS serializer and improved configurable serializer #1165
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
Open
mgoworko
wants to merge
18
commits into
sscarduzio:develop
Choose a base branch
from
mgoworko:RORDEV-1567
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
e8dc296
qs
mgoworko d7f70e0
qs
mgoworko b3c3ba8
Merge remote-tracking branch 'origin/develop' into RORDEV-1567
mgoworko 2b6454e
Merge remote-tracking branch 'origin/develop' into RORDEV-1567
mgoworko ff5f100
qs
mgoworko 1c5f7a4
qs
mgoworko 944662b
ECS schema version field
mgoworko f940792
add ECS serializer integration test
mgoworko a57e942
Merge remote-tracking branch 'origin/develop' into RORDEV-1567
mgoworko 59e4797
rabbit review change
mgoworko c0ca654
rabbit review change
mgoworko aa15975
rabbit review change
mgoworko 51ed19d
review changes
mgoworko 96304a7
review changes
mgoworko 08f8c99
Merge remote-tracking branch 'origin/develop' into RORDEV-1567
mgoworko 3f63b3b
adjust tests
mgoworko e5c2e90
review changes
mgoworko 7b2aa60
Merge remote-tracking branch 'origin/develop' into RORDEV-1567
mgoworko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
core/src/main/scala/tech/beshu/ror/accesscontrol/audit/ecs/EcsV1AuditLogSerializer.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| /* | ||
| * This file is part of ReadonlyREST. | ||
| * | ||
| * ReadonlyREST is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * ReadonlyREST is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with ReadonlyREST. If not, see http://www.gnu.org/licenses/ | ||
| */ | ||
| package tech.beshu.ror.accesscontrol.audit.ecs | ||
|
|
||
| import org.json.JSONObject | ||
| import tech.beshu.ror.accesscontrol.audit.ecs.EcsV1AuditLogSerializer.fields | ||
| import tech.beshu.ror.audit.utils.AuditSerializationHelper | ||
| import tech.beshu.ror.audit.utils.AuditSerializationHelper.{AllowedEventMode, AuditFieldName, AuditFieldValueDescriptor} | ||
| import tech.beshu.ror.audit.{AuditLogSerializer, AuditResponseContext} | ||
|
|
||
| class EcsV1AuditLogSerializer(val allowedEventMode: AllowedEventMode) extends AuditLogSerializer { | ||
|
|
||
| override def onResponse(responseContext: AuditResponseContext): Option[JSONObject] = { | ||
| AuditSerializationHelper.serialize(responseContext, fields, allowedEventMode) | ||
| } | ||
|
|
||
| } | ||
|
|
||
| object EcsV1AuditLogSerializer { | ||
| private val fields: Map[AuditFieldName, AuditFieldValueDescriptor] = Map( | ||
coutoPL marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| AuditFieldName("ecs") -> AuditFieldValueDescriptor.Nested( | ||
| // Schema defined by EcsV1AuditLogSerializer is ECS 1.4.0 compliant and does not use newer features introduced by later versions | ||
coutoPL marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| AuditFieldName("version") -> AuditFieldValueDescriptor.StaticText("1.4.0"), | ||
| ), | ||
| AuditFieldName("@timestamp") -> AuditFieldValueDescriptor.Timestamp, | ||
| AuditFieldName("trace") -> AuditFieldValueDescriptor.Nested( | ||
| AuditFieldName("id") -> AuditFieldValueDescriptor.CorrelationId, | ||
| ), | ||
| AuditFieldName("url") -> AuditFieldValueDescriptor.Nested( | ||
| AuditFieldName("path") -> AuditFieldValueDescriptor.HttpPath, | ||
| ), | ||
| AuditFieldName("source") -> AuditFieldValueDescriptor.Nested( | ||
| AuditFieldName("address") -> AuditFieldValueDescriptor.RemoteAddress, | ||
| ), | ||
| AuditFieldName("destination") -> AuditFieldValueDescriptor.Nested( | ||
| AuditFieldName("address") -> AuditFieldValueDescriptor.LocalAddress, | ||
| ), | ||
| AuditFieldName("http") -> AuditFieldValueDescriptor.Nested( | ||
| AuditFieldName("request") -> AuditFieldValueDescriptor.Nested( | ||
| AuditFieldName("method") -> AuditFieldValueDescriptor.HttpMethod, | ||
| AuditFieldName("body") -> AuditFieldValueDescriptor.Nested( | ||
| AuditFieldName("content") -> AuditFieldValueDescriptor.Content, | ||
| AuditFieldName("bytes") -> AuditFieldValueDescriptor.ContentLengthInBytes, | ||
| ), | ||
| ), | ||
| ), | ||
| AuditFieldName("user") -> AuditFieldValueDescriptor.Nested( | ||
| AuditFieldName("name") -> AuditFieldValueDescriptor.User, | ||
| AuditFieldName("effective") -> AuditFieldValueDescriptor.Nested( | ||
| AuditFieldName("name") -> AuditFieldValueDescriptor.ImpersonatedByUser, | ||
| ), | ||
| ), | ||
| AuditFieldName("event") -> AuditFieldValueDescriptor.Nested( | ||
| AuditFieldName("id") -> AuditFieldValueDescriptor.Id, | ||
| AuditFieldName("action") -> AuditFieldValueDescriptor.Action, | ||
| AuditFieldName("type") -> AuditFieldValueDescriptor.Type, | ||
| AuditFieldName("reason") -> AuditFieldValueDescriptor.FinalState, | ||
| AuditFieldName("duration") -> AuditFieldValueDescriptor.ProcessingDurationNanos, | ||
| ), | ||
coutoPL marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| AuditFieldName("error") -> AuditFieldValueDescriptor.Nested( | ||
| AuditFieldName("type") -> AuditFieldValueDescriptor.ErrorType, | ||
| AuditFieldName("message") -> AuditFieldValueDescriptor.ErrorMessage, | ||
| ), | ||
| AuditFieldName("labels") -> AuditFieldValueDescriptor.Nested( | ||
| AuditFieldName("es_cluster_name") -> AuditFieldValueDescriptor.EsClusterName, | ||
| AuditFieldName("es_node_name") -> AuditFieldValueDescriptor.EsNodeName, | ||
| AuditFieldName("es_task_id") -> AuditFieldValueDescriptor.TaskId, | ||
| AuditFieldName("involved_indices") -> AuditFieldValueDescriptor.InvolvedIndices, | ||
| AuditFieldName("acl_history") -> AuditFieldValueDescriptor.AclHistory, | ||
| AuditFieldName("x_forwarded_for") -> AuditFieldValueDescriptor.XForwardedForHttpHeader, | ||
| ), | ||
| ) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.