axoflow / axosyslog

AxoSyslog - the scalable security data processor
https://axoflow.com
Other
45 stars 14 forks source link

fix(lib): check generator_args value before using it #254

Open OverOrion opened 1 month ago

OverOrion commented 1 month ago
@version: current

block destination second(...) {
      `__VARARGS__`
};

block destination first(...) {
      second(`__VARARGS__`);
};

log {
   destination{ first(some-param("")) };
};

After the fix:

[2024-08-13T09:19:13.979827] Starting to read include file; filename='/source/install_dir/etc/foo.conf', depth='0'
[2024-08-13T09:19:13.979827] Setting current version as config version; version='4.8'
[2024-08-13T09:19:13.979827] Unknown argument, adding it to __VARARGS__; argument='some_param', value='', reference='/source/install_dir/etc/foo.conf:12:17'
[2024-08-13T09:19:13.979827] Unknown argument, adding it to __VARARGS__; argument='some_param', value='(null)', reference='/source/install_dir/etc/foo.conf:8:7'

Error parsing log statement: syntax error, unexpected LL_IDENTIFIER, expecting '}'

In block destination second() at /source/install_dir/etc/foo.conf:3:5:7-5:17:
1
2       #Start Block block destination second() at /source/install_dir/etc/foo.conf:3
3       ## some_param=@line "/source/install_dir/etc/foo.conf" 3 31
4
5----->       some_param()
5----->       ^^^^^^^^^^
6
7       #End Block block destination second() at /source/install_dir/etc/foo.conf:3
8

Included from /source/install_dir/etc/foo.conf:8:7-8:28:
3
4       #Start Block block destination first() at /source/install_dir/etc/foo.conf:7
5       ## some_param=
6       @line "/source/install_dir/etc/foo.conf" 7 30
7
8----->       second(some_param() );
8----->       ^^^^^^^^^^^^^^^^^^^^^
9
10      #End Block block destination first() at /source/install_dir/etc/foo.conf:7
11

Included from /source/install_dir/etc/foo.conf:12:17-12:38:
7       block destination first(...) {
8             second(`__VARARGS__`);
9       };
10
11      log {
12---->    destination{ first(some-param("")) };
12---->                 ^^^^^^^^^^^^^^^^^^^^^
13      };

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
[2024-08-13T09:19:13.979827] Running application hooks; hook='4'

Fixes #244.

OverOrion commented 1 month ago

On a second thought this might not be a proper fix:

[2024-08-13T09:19:13.979827] Unknown argument, adding it to __VARARGS__; argument='some_param', value='', reference='/source/install_dir/etc/foo.conf:12:17'
[2024-08-13T09:19:13.979827] Unknown argument, adding it to __VARARGS__; argument='some_param', value='(null)', reference='/source/install_dir/etc/foo.conf:8:7'

The value gets lost somewhere :eyes:

alltilla commented 1 month ago

Another config that crashes at the same location:

@version: current

block destination a(filtr(def)) {
  channel {
    filter {
      `filtr`
      and 1 == 1};
  };
};

destination d { a(filtr()); };