-
Notifications
You must be signed in to change notification settings - Fork 475
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
Driver specific template escaping #4666
Merged
alltilla
merged 22 commits into
syslog-ng:master
from
bazsi:driver-specific-template-escaping
Oct 19, 2023
Merged
Driver specific template escaping #4666
alltilla
merged 22 commits into
syslog-ng:master
from
bazsi:driver-specific-template-escaping
Oct 19, 2023
Conversation
This file contains 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
Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
bazsi
force-pushed
the
driver-specific-template-escaping
branch
2 times, most recently
from
October 9, 2023 07:28
c94b47c
to
89a7410
Compare
Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
In order to recurse into our grammar we can't use global variables to track objects we are parsing into. This solution uses the $0 value for rule actions to pass arguments to that specific rule, this time the LogTemplate instance we need to parse into. That way the LogTemplate instance would be separate even if we are recursing into the same parts of the grammar. A similar solution could potentially be established to all similar cases, using global variables in a recursive grammar is not right. Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
To be able to use separate grammar rules for template references and inline templates. Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
…dule Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
A top_level LogTemplate is one which is instantiated directly from the configuration or by a driver. For embedded LogTemplate instances (e.g. within function invocations), this is FALSE. The idea is that some operations (e.g. escaping) are only performed at the top level. Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
With this patch it becomes possible to enable escaping from both the LogTemplate side (e.g. when template-escape(yes) is present in a template statement) and the LogTemplateOptions side (e.g. with the destination driver specific template-escape()) option. Previously only LogWriter supplied this setting and it only worked in case of an inline template. With this change, this works with all drivers that support the `template_option` grammar rule. Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
Earlier, template functions were performing escaping as a part of their own expansion of macros/values. This means that a template-escape(yes) template, with embedded template functions, the template functions received its arguments in an escaped form. For example this template: template t_escaped { template("$(echo $(length ${value}))"); template-escape(yes) }; where $value contains characters that need to be escaped (e.g. quotes or control characters), $(length) received the escaped format. This patch changes this behaviour slightly by: 1) embedded template expressions always get strings in an unescaped form 2) the end result of functions are escaped at the top-level. Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
This patch moves escaping to one layer higher, thereby ensuring a consistent escaping implmentation and simplifying the lower layers. Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
With this change the call-site of log_template_format_*() family of functions can supply a custom escaping mechanism. Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
bazsi
force-pushed
the
driver-specific-template-escaping
branch
from
October 14, 2023 04:42
89a7410
to
7be4356
Compare
alltilla
reviewed
Oct 19, 2023
tests/light/src/syslog_ng_config/statements/template/template.py
Outdated
Show resolved
Hide resolved
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
alltilla
approved these changes
Oct 19, 2023
alltilla
added a commit
to alltilla/syslog-ng
that referenced
this pull request
Oct 20, 2023
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
alltilla
added a commit
to alltilla/syslog-ng
that referenced
this pull request
Oct 24, 2023
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
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.
This is an alternative for #4664 which generalizes template-escape() to allow driver specific escaping modes and also makes it easy for drivers to request escaping of a template expansion.
The idea is to allow the http() destination to use templates in the url() parameter. Allowing unsanitized input in an URL string could pose a security risk, so doing URL encoding of the values make would make sense.