Skip to content
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
merged 22 commits into from
Oct 19, 2023

Commits on Oct 8, 2023

  1. light: move stringify outside of the SyslogNGConfig class

    Signed-off-by: Balazs Scheidler <[email protected]>
    bazsi committed Oct 8, 2023
    Configuration menu
    Copy the full SHA
    a859450 View commit details
    Browse the repository at this point in the history

Commits on Oct 14, 2023

  1. light: add support for set()

    Signed-off-by: Balazs Scheidler <[email protected]>
    bazsi committed Oct 14, 2023
    Configuration menu
    Copy the full SHA
    65a2859 View commit details
    Browse the repository at this point in the history
  2. light: add support for creating template statements

    Signed-off-by: Balazs Scheidler <[email protected]>
    bazsi committed Oct 14, 2023
    Configuration menu
    Copy the full SHA
    1744b38 View commit details
    Browse the repository at this point in the history
  3. light: add testcases to exercise templates

    Signed-off-by: Balazs Scheidler <[email protected]>
    bazsi committed Oct 14, 2023
    Configuration menu
    Copy the full SHA
    37432b5 View commit details
    Browse the repository at this point in the history
  4. cfg-grammar.y: extract template_name_or_content rule

    Signed-off-by: Balazs Scheidler <[email protected]>
    bazsi committed Oct 14, 2023
    Configuration menu
    Copy the full SHA
    59be6b2 View commit details
    Browse the repository at this point in the history
  5. cfg-grammar.y: move template_item rule

    Signed-off-by: Balazs Scheidler <[email protected]>
    bazsi committed Oct 14, 2023
    Configuration menu
    Copy the full SHA
    9fd3b31 View commit details
    Browse the repository at this point in the history
  6. cfg-grammar: eliminate last_template variable

    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 <[email protected]>
    bazsi committed Oct 14, 2023
    Configuration menu
    Copy the full SHA
    7f05114 View commit details
    Browse the repository at this point in the history
  7. cfg-grammar: use lexer context to recognize named templates

    To be able to use separate grammar rules for template references
    and inline templates.
    
    Signed-off-by: Balazs Scheidler <[email protected]>
    bazsi committed Oct 14, 2023
    Configuration menu
    Copy the full SHA
    a11ce5a View commit details
    Browse the repository at this point in the history
  8. template: move template related global logic/variables to separate mo…

    …dule
    
    Signed-off-by: Balazs Scheidler <[email protected]>
    bazsi committed Oct 14, 2023
    Configuration menu
    Copy the full SHA
    5a15f0f View commit details
    Browse the repository at this point in the history
  9. template: move LogTemplateOptions to common_template_typedefs

    Signed-off-by: Balazs Scheidler <[email protected]>
    bazsi committed Oct 14, 2023
    Configuration menu
    Copy the full SHA
    6a8f7c6 View commit details
    Browse the repository at this point in the history
  10. template: extract log_template_append_elem_value()

    Signed-off-by: Balazs Scheidler <[email protected]>
    bazsi committed Oct 14, 2023
    Configuration menu
    Copy the full SHA
    06eeb2e View commit details
    Browse the repository at this point in the history
  11. template: extract log_template_append_elem_macro()

    Signed-off-by: Balazs Scheidler <[email protected]>
    bazsi committed Oct 14, 2023
    Configuration menu
    Copy the full SHA
    35ab205 View commit details
    Browse the repository at this point in the history
  12. template: extract log_template_append_elem_func()

    Signed-off-by: Balazs Scheidler <[email protected]>
    bazsi committed Oct 14, 2023
    Configuration menu
    Copy the full SHA
    7b19fc9 View commit details
    Browse the repository at this point in the history
  13. template: differentiate top-level and embedded template expressions

    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 <[email protected]>
    bazsi committed Oct 14, 2023
    Configuration menu
    Copy the full SHA
    1ac5d9c View commit details
    Browse the repository at this point in the history
  14. template: add "escape" setting to LogTemplateOptions as well

    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 <[email protected]>
    bazsi committed Oct 14, 2023
    Configuration menu
    Copy the full SHA
    bb90c4d View commit details
    Browse the repository at this point in the history
  15. template: perform escaping on the result of functions

    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 <[email protected]>
    bazsi committed Oct 14, 2023
    Configuration menu
    Copy the full SHA
    d1e9e64 View commit details
    Browse the repository at this point in the history
  16. template: apply escaping to all kinds of LogTemplateElems

    This patch moves escaping to one layer higher, thereby ensuring a consistent
    escaping implmentation and simplifying the lower layers.
    
    Signed-off-by: Balazs Scheidler <[email protected]>
    bazsi committed Oct 14, 2023
    Configuration menu
    Copy the full SHA
    e4b22c2 View commit details
    Browse the repository at this point in the history
  17. template: remove escaping support from macro expansion

    Signed-off-by: Balazs Scheidler <[email protected]>
    bazsi committed Oct 14, 2023
    Configuration menu
    Copy the full SHA
    38ffb93 View commit details
    Browse the repository at this point in the history
  18. template: use simple g_string_append_len() instead of result_append()

    Signed-off-by: Balazs Scheidler <[email protected]>
    bazsi committed Oct 14, 2023
    Configuration menu
    Copy the full SHA
    ab14167 View commit details
    Browse the repository at this point in the history
  19. template: add support for escape callback through LogTemplateEvalOptions

    With this change the call-site of log_template_format_*() family of
    functions can supply a custom escaping mechanism.
    
    Signed-off-by: Balazs Scheidler <[email protected]>
    bazsi committed Oct 14, 2023
    Configuration menu
    Copy the full SHA
    7be4356 View commit details
    Browse the repository at this point in the history

Commits on Oct 19, 2023

  1. light: fix copyright holder

    Signed-off-by: Attila Szakacs <[email protected]>
    alltilla committed Oct 19, 2023
    Configuration menu
    Copy the full SHA
    b8723c8 View commit details
    Browse the repository at this point in the history
  2. light: remove duplicate import

    Signed-off-by: Attila Szakacs <[email protected]>
    alltilla committed Oct 19, 2023
    Configuration menu
    Copy the full SHA
    2b79680 View commit details
    Browse the repository at this point in the history