This is a small follow-up post to my previous post on LUA transformation rules to retrieve external data WebSEAL LUA http transformation rules with external data

A blog post by my colleague got me thinking that we could use the LUA transformation rules for logging to REST logging systems:

So let’s try this out!

Since I don’t have a QRadar installation handy, I’m using Loggly here. The events are sent using HTTP POST in both cases, so it’s likely that you can exchange the Loggly endpoint with a QRadar endpoint.


I’ve registered for a trial account at Loggly, since that seemed to be the fastest way to get a logging http endpoint up and running.

The HTTP/HTTPS event logger can be accessed by urls like this:

curl -H "content-type:text/plain" -d "Hello"<TOKEN>/tag/http/

The <TOKEN> is linked to your account, so private.

Note that this is a HTTP POST request.

Transformation rule with http.requests

You can edit the loguri parameter to point to your own personal loggly account. Replace the <TOKEN> with your personal token.

Save the script in the current directory as logglylua (for the test)

local request = require "http.request"
local cjson = require "cjson"

local http_headers = require "http.headers"

local r =  assert(request.new_from_uri("<TOKEN>/tag/isva/"))
r.headers:upsert(":method", "POST")
r.headers:upsert("content-type", "application/json")
assert(r:set_body('{"url": "'..HTTPRequest.getURL()..'", "username": "'..Session.getUsername()..'"}'))

local h, res = assert(r:go())

Control.trace(5, res:get_body_as_string())

So this transformation rule will send the URL and the username to the http logging endpoint. Note that this is only a proof of concept, you’d need to verify that there is an authenticated session (otherwise the lua script will throw an error).

Examples for lua

The http-request modules are included with ISVA 10.0.4+, but it’s a bit difficult to find examples.
The source on Github actually contains the best examples.

Test the rule

Prepare context.yaml

You can generate a context.yaml using dumpContext (in lua script), or by creating one yourself. See this blog post on how to do that : WebSEAL LUA http transformation rules with external data, or check the official documentation.

I’m using this example context:

    method: "GET"
    url:    "/junction1/index.html"
      - name:  "User-Agent"
        value: "curl"
      - name:  "Host"
        value: ""
  username: "testuser"
      - name:  "AZN_CRED_PRINCIPAL_NAME"
        value: "testuser"

Run the test

You should now have 2 files in the current directory:

  • loggly.lua ( the actual lua script )
  • context.yaml (the webseal context)
podman run --rm -v ${PWD}:/lua_test:z --entrypoint iag_lua_transformation_test \ -c /lua_test/context.yaml -s /lua_test/loggly.lua

Note: in podman, the :z option in the volume mount seems necessary. The error message is not particularly helpful, but if you get the message below, it’s likely the volume mount files are not accessible by the container. DPWWA3301E A failure occurred while parsing the YAML file: /var/iag/staging/context.yaml (bad file) The reason is that the files actually should have system_u:object_r:container_file_t:s0 as selinux context. If you run the above podman command once with the :z option, the selinux context is updated and :z is no longer necessary.

If all goes well, you get this output in the cli.

Lua trace (level: 5): {"response" : "ok"}

In Loggly, it will look like something like this: Image:loggly results

Notice that the json message that we sent in the LUA rule, is parsed in separate fields.

WebSeal configuration


Once you’ve tested the rule, you can deploy it in WebSEAL.

Edit the webseald.conf, and add a request-match entry.

This example is similar to the logging similar to the blogpost by Hans (to log AAC authentication)

loghttp = loggly.lua

request-match = request:* /mga/*