Skip to content

LOG-6863: safety parsing/read fields to avoid messing data in log event #3031

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

Draft
wants to merge 2 commits into
base: release-6.1
Choose a base branch
from

Conversation

vparfonov
Copy link
Contributor

@vparfonov vparfonov commented Apr 24, 2025

Description

This PR addresses an issue where data in a Syslog log event could become corrupted after a merge operation. Such behavior can lead to unpredictable and hard-to-diagnose issues.

The fix involves parsing and merging data into a temporary value, from which the necessary information is extracted. This ensures that the original log event remains structured and valid.

/cc
/assign

Links

  • Depending on PR(s):
  • GitHub issue:
  • JIRA:
  • Enhancement proposal:

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Apr 24, 2025
@openshift-ci-robot
Copy link

openshift-ci-robot commented Apr 24, 2025

@vparfonov: This pull request references LOG-6863 which is a valid jira issue.

In response to this:

Description

/cc
/assign

Links

  • Depending on PR(s):
  • GitHub issue:
  • JIRA:
  • Enhancement proposal:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 24, 2025
Copy link
Contributor

openshift-ci bot commented Apr 24, 2025

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

Copy link
Contributor

openshift-ci bot commented Apr 24, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: vparfonov
Once this PR has been reviewed and has the lgtm label, please assign xperimental for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot
Copy link

openshift-ci-robot commented Apr 24, 2025

@vparfonov: This pull request references LOG-6863 which is a valid jira issue.

In response to this:

Description

This PR addresses an issue where data in a Syslog log event could become corrupted after a merge operation. Such behavior can lead to unpredictable and hard-to-diagnose issues.

The fix involves parsing and merging data into a temporary value, from which the necessary information is extracted. This ensures that the original log event remains structured and valid.

/cc
/assign

Links

  • Depending on PR(s):
  • GitHub issue:
  • JIRA:
  • Enhancement proposal:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@vparfonov
Copy link
Contributor Author

/test all

Makefile Outdated
RELATED_IMAGE_VECTOR=$(IMAGE_LOGGING_VECTOR) \
RELATED_IMAGE_LOG_FILE_METRIC_EXPORTER=$(IMAGE_LOGFILEMETRICEXPORTER) \
go test -race \
./test/functional/... \
./test/functional/outputs/syslog/... \
Copy link
Contributor

Choose a reason for hiding this comment

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

This means we will only test this package and none of the others

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I add this for fast testing

Makefile Outdated
@@ -216,11 +216,11 @@ test-env: ## Echo test environment, useful for running tests outside of the Make
RELATED_IMAGE_LOG_FILE_METRIC_EXPORTER=$(IMAGE_LOGFILEMETRICEXPORTER) \

.PHONY: test-functional
test-functional: test-functional-benchmarker-vector
test-functional:
Copy link
Contributor

Choose a reason for hiding this comment

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

removing this dependency means we never compile the dev tool

if s.Facility == "" {
s.Facility = `{._internal.syslog.facility || "user"}`
appendField := func(fieldName string, value *string, defaultVal string) {
if *value == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible for "value" to be nil since its a pointer? Do we need to ensure it's non-nil? why do we need to pass a pointer string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The pointer we use to set the field in struct if need

@@ -22,6 +20,15 @@ if .log_type == "audit" {
._internal.syslog.severity = "informational"
._internal.syslog.facility = "security"
}
_tmp, err = parse_json(string!(.message))
Copy link
Contributor

Choose a reason for hiding this comment

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

I missing the intent of this section:

  • parse message to temp
  • error we set temp to the log event
  • non error we set temp to the merge of the message and the log event
  • set field parsed_msg

we do not appear to do anything with the parsed_msg so we do any of this?

Copy link
Contributor Author

@vparfonov vparfonov Apr 24, 2025

Choose a reason for hiding this comment

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

yes you are right here in this case it will not be used because will use default value, need to improve this part

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 Author

Choose a reason for hiding this comment

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

By the way we can remove default calculation if value configured

Signed-off-by: Vitalii Parfonov <[email protected]>
@vparfonov
Copy link
Contributor Author

/test all

@vparfonov
Copy link
Contributor Author

/retest

Copy link
Contributor

openshift-ci bot commented Apr 25, 2025

@vparfonov: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. release/6.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants