Skip to content

Conversation

@bazsi
Copy link

@bazsi bazsi commented Oct 8, 2023

This branch adds the new #4666 plus a couple of patches to your http stuff so that we properly escape the URLs as needed.

Instead of merging this, you might want to rebase against syslog-ng#4666 and add the last two patches only.

alltilla and others added 28 commits October 3, 2023 15:15
This prepares easier transition to templated urls.

Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
Currently the http-worker is only using the literal functionality.
Implementing support there will be done in the following commits.

Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
If we are batching, the first message of the batch will be used
for the template evaluation.

Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
I believe the only use case of using worker-partition-key() in the
http() driver is when we are configuring a templated url().

In that scenario we should be flushing on worker key change.

Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
Signed-off-by: Attila Szakacs <attila.szakacs@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>
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>
Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
@alltilla
Copy link
Owner

Thanks, rebased my PR.

@alltilla alltilla closed this Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants