Discussion:
How to use sanitize fields for json output
Enrico Polesel
2018-11-11 10:39:12 UTC
Permalink
Hi all,

I want to use the linelog module to print logs in a machine readable format
for my ELK stack, I would like to print them in json.

I would like to have user controlled fields (like the username) sanitized,
from an old discussion[1] in this mailing list I find out that there is a
"jsonquote" xlat expansion available, so I tried to use it but with little
success since the module is unknown.

(0) linelog: ERROR: %T request [%{jsonquote:request:User-Name}] ....
(0) linelog: ERROR: ^ Unknown module
After a quick search in the wiki[2] I found out that the jsonquote xlat is
provided by the rlm_rest module. So I tried to enable it adding in
`mods-enabled` a symlink to the configuration file, but then the freeradius
server fails to start since the module is not configured (for example it
tries to connect to localhost but i have no web services enabled on the VM).


Is "jsonquote" the right way to achieve this? If it is, how can I use it
without configuring properly (and pointing to a real web server) the rest
module?


Thank you,
Enrico Polesel


[1]
http://lists.freeradius.org/pipermail/freeradius-users/2017-January/086317.html

[2] https://wiki.freeradius.org/config/Xlat#provided-by-modules_rlm_rest
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/u
Alan Buxey
2018-11-11 13:07:48 UTC
Permalink
hi,

just comment out the connection part and set the start to 0 in the pool.

however, are you sure your server was built with json support?

alan
-
List info/subscribe/u
Enrico Polesel
2018-11-12 07:35:27 UTC
Permalink
Hi,

I'll reply inline.
Post by Alan Buxey
hi,
just comment out the connection part and set the start to 0 in the pool.
That was also written in the comments, sorry for not seeing that. I did it
and now it works. Thank you!

Just for completeness (for future readers), the right way to use the xlat
is "%{jsonquote:%{request:User-Name}}".
Post by Alan Buxey
however, are you sure your server was built with json support?
I think so because jsonquote is working, but I should check the build
process. I compile myself the deb packages using the instruction of this
page: https://wiki.freeradius.org/building/Debian%20and%20Ubuntu


Just as a note, it may be useful to move the jsonquote xlat from the rest
module to the server core since I think that uses like mine aren't too
exotic.


Thank you for all,
best regards,
Enrico Polesel
-
List info/subscribe/u
Herwin Weststrate
2018-11-12 09:29:08 UTC
Permalink
Post by Enrico Polesel
Post by Alan Buxey
however, are you sure your server was built with json support?
I think so because jsonquote is working, but I should check the build
process. I compile myself the deb packages using the instruction of this
page: https://wiki.freeradius.org/building/Debian%20and%20Ubuntu
Building Debian packages requires you to have all the development
libraries available, so this ensures JSON support
Post by Enrico Polesel
Just as a note, it may be useful to move the jsonquote xlat from the rest
module to the server core since I think that uses like mine aren't too
exotic.
Version 4.0 has (will have) this extracted to a rlm_json. I don't think
if would be a very bad idea to backport this to v3.0.x.
--
Herwin Weststrate
-
List info/subscribe/unsubscribe? See
Matthew Newton
2018-11-12 12:01:17 UTC
Permalink
Post by Herwin Weststrate
Post by Enrico Polesel
Just as a note, it may be useful to move the jsonquote xlat from the rest
module to the server core since I think that uses like mine aren't too
exotic.
Version 4.0 has (will have) this extracted to a rlm_json. I don't think
if would be a very bad idea to backport this to v3.0.x.
Which may break configs which already use rlm_rest for that xlat, and
don't include the new module when they upgrade.

It already works in v3 with the right configuration; I don't really see
a good reason to change it.
--
Matthew

-
List info/subscribe/unsubscribe? Se
Loading...