axosyslog icon indicating copy to clipboard operation
axosyslog copied to clipboard

cache_json_file() reports `function not found` if the json file is empty

Open orymate opened this issue 1 year ago • 0 comments

AxoSyslog

Version of AxoSyslog

/ # syslog-ng --version
axosyslog 4 (4.8.0.227.g9cd21c6)
Config version: 4.2
Installer-Version: 4.8.0.227.g9cd21c6+4.8.0_git20240827
Revision: 
Compile-Date: Aug 27 2024 23:09:55
Module-Directory: /usr/lib/syslog-ng
Module-Path: /usr/lib/syslog-ng
Include-Path: /usr/share/syslog-ng/include
Available-Modules: afprog,syslogformat,regexp-parser,cryptofuncs,afsql,afmongodb,mod-python,affile,http,cef,redis,examples,stardate,mqtt,loki,graphite,riemann,afuser,metrics-probe,correlation,tags-parser,afsocket,linux-kmsg-format,kvformat,secure-logging,azure-auth-header,afstomp,afsnmp,geoip2-plugin,rate-limit-filter,otel,timestamp,kafka,disk-buffer,add-contextual-data,appmodel,csvparser,ebpf,xml,map-value-pairs,confgen,system-source,afamqp,cloud_auth,pseudofile,hook-commands,bigquery,basicfuncs,json-plugin
Enable-Debug: off
Enable-GProf: off
Enable-Memtrace: off
Enable-IPv6: on
Enable-Spoof-Source: on
Enable-TCP-Wrapper: off
Enable-Linux-Caps: off
Enable-Systemd: off

Platform

x86_64 linux (nightly docker image)

Issue

Failure

When calling cache_json_file with an (almost) empty json file, AxoSyslog reports Error parsing filterx expression: cache_json_file(): function not found instead of allowing for empty files (as null or something), or reporting an error pointing out that the json file is empty.

Examples for Json files triggering this:

  • "" (0 bytes)
  • "\n"
  • "{\n"

Not every invalid file is handled incorrectly:

  • "invalid" -> Error parsing filterx expression: cache_json_file(): failed to parse JSON file: json (unexpected character)

Steps to reproduce

/ # syslog-ng -F -f test2.conf 

Error parsing filterx expression: cache_json_file(): function not found

In test2.conf:4:5-4:28:
1       @version: current
2       log {
3         filterx {
4----->     cache_json_file("json");
4----->     ^^^^^^^^^^^^^^^^^^^^^^^
5         };
6       };


syslog-ng documentation: https://axoflow.com/docs/axosyslog-core/
contact: 
	GitHub Project: https://github.com/axoflow/axosyslog
	Chat with the Developers: https://discord.gg/E65kP9aZGm
/ # echo {} >json
/ # syslog-ng -F -f test2.conf 
^C/ # 
/ # 

Configuration

/ # cat test2.conf 
@version: current
log {
  filterx {
    cache_json_file("json");
  };
};
/ # cat json 

Input and output logs (if possible)

orymate avatar Aug 29 '24 05:08 orymate