FEATURE:: Adding -oaddFieldsPosition flag to capture fields position#15
Draft
FEATURE:: Adding -oaddFieldsPosition flag to capture fields position#15
Conversation
frikilax
reviewed
Jun 13, 2025
Comment on lines
+3139
to
+3154
| ln_recordfieldposition(npb, "DeviceVendor", iHdrStart, i-1); | ||
| iHdrStart = i; | ||
| CHKR(cefGetHdrField(npb, &i, (value == NULL) ? NULL : &product)); | ||
| ln_recordfieldposition(npb, "DeviceProduct", iHdrStart, i-1); | ||
| iHdrStart = i; | ||
| CHKR(cefGetHdrField(npb, &i, (value == NULL) ? NULL : &version)); | ||
| ln_recordfieldposition(npb, "DeviceVersion", iHdrStart, i-1); | ||
| iHdrStart = i; | ||
| CHKR(cefGetHdrField(npb, &i, (value == NULL) ? NULL : &sigID)); | ||
| ln_recordfieldposition(npb, "SignatureID", iHdrStart, i-1); | ||
| iHdrStart = i; | ||
| CHKR(cefGetHdrField(npb, &i, (value == NULL) ? NULL : &name)); | ||
| ln_recordfieldposition(npb, "Name", iHdrStart, i-1); | ||
| iHdrStart = i; | ||
| CHKR(cefGetHdrField(npb, &i, (value == NULL) ? NULL : &severity)); | ||
| ln_recordfieldposition(npb, "Severity", iHdrStart, i-1); |
Member
There was a problem hiding this comment.
i-1 ?
isn't it i+1 ?
And I don't think all fields are 1 char long
Author
There was a problem hiding this comment.
I tried with i-1. It works great.
| if (npb == NULL || npb->fieldposition == NULL || npb->field_path == NULL || fieldName == NULL) { | ||
| return; | ||
| } | ||
| if (fieldName[0] == '.' && fieldName[1] == '\0') { |
Member
There was a problem hiding this comment.
why not?
Suggested change
| if (fieldName[0] == '.' && fieldName[1] == '\0') { | |
| if (fieldName[0] == '.' && fieldName[1] == NULL) { |
Comment on lines
+165
to
+166
| struct json_object *fieldposition; /**< field logspan data */ | ||
| struct json_object *field_path; /**< field logspan path stack */ |
added 12 commits
June 13, 2025 14:22
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adding -oaddFieldsPosition flag to liblognorm
The -oaddFieldsPosition flag is made to enable the tracking of the position of each field's value in the input log.
The output is a new field under "metadata" which has the same structure as the base fields but the values are replaced with an array of two indices.
Example
A
__fieldpositionfield is also added under each new nested level of json so as to track the whole position of the group.For example here, the field __fieldposition was added under
metadata.fields_position.parent_dataand says that theparent_datafield started at index 5 and ended at index 944.Limitations
This feature does not work for the fields created by the following types: