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
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
a859450
light: move stringify outside of the SyslogNGConfig class
bazsi Oct 7, 2023
65a2859
light: add support for set()
bazsi Oct 7, 2023
1744b38
light: add support for creating template statements
bazsi Oct 5, 2023
37432b5
light: add testcases to exercise templates
bazsi Oct 5, 2023
59be6b2
cfg-grammar.y: extract template_name_or_content rule
bazsi Oct 5, 2023
9fd3b31
cfg-grammar.y: move template_item rule
bazsi Oct 5, 2023
7f05114
cfg-grammar: eliminate last_template variable
bazsi Oct 5, 2023
a11ce5a
cfg-grammar: use lexer context to recognize named templates
bazsi Oct 5, 2023
5a15f0f
template: move template related global logic/variables to separate mo…
bazsi Oct 7, 2023
6a8f7c6
template: move LogTemplateOptions to common_template_typedefs
bazsi Oct 7, 2023
06eeb2e
template: extract log_template_append_elem_value()
bazsi Oct 7, 2023
35ab205
template: extract log_template_append_elem_macro()
bazsi Oct 7, 2023
7b19fc9
template: extract log_template_append_elem_func()
bazsi Oct 7, 2023
1ac5d9c
template: differentiate top-level and embedded template expressions
bazsi Oct 8, 2023
bb90c4d
template: add "escape" setting to LogTemplateOptions as well
bazsi Oct 7, 2023
d1e9e64
template: perform escaping on the result of functions
bazsi Oct 8, 2023
e4b22c2
template: apply escaping to all kinds of LogTemplateElems
bazsi Oct 8, 2023
38ffb93
template: remove escaping support from macro expansion
bazsi Oct 8, 2023
ab14167
template: use simple g_string_append_len() instead of result_append()
bazsi Oct 8, 2023
7be4356
template: add support for escape callback through LogTemplateEvalOptions
bazsi Oct 8, 2023
b8723c8
light: fix copyright holder
alltilla Oct 19, 2023
2b79680
light: remove duplicate import
alltilla Oct 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions tests/light/src/syslog_ng_config/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python
#############################################################################
# Copyright (c) 2015-2018 Balabit
alltilla marked this conversation as resolved.
Show resolved Hide resolved
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 as published
# by the Free Software Foundation, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# As an additional exemption you are allowed to compile & link against the
# OpenSSL libraries as published by the OpenSSL project. See the file
# COPYING for details.
#
#############################################################################


def stringify(s):
return '"' + s.replace('\\', "\\\\").replace('"', '\\"').replace('\n', '\\n') + '"'
5 changes: 2 additions & 3 deletions tests/light/src/syslog_ng_config/syslog_ng_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

from src.common.file import File
from src.common.operations import cast_to_list
from src.syslog_ng_config import stringify
from src.syslog_ng_config.renderer import ConfigRenderer
from src.syslog_ng_config.statement_group import StatementGroup
from src.syslog_ng_config.statements.destinations.example_destination import ExampleDestination
Expand Down Expand Up @@ -62,9 +63,7 @@ def __init__(self, version, teardown):
}
self.teardown = teardown

@staticmethod
def stringify(s):
return '"' + s.replace('\\', "\\\\").replace('"', '\\"').replace('\n', '\\n') + '"'
stringify = staticmethod(stringify)

def set_raw_config(self, raw_config):
self.__raw_config = raw_config
Expand Down