-
Notifications
You must be signed in to change notification settings - Fork 215
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
auparse_next_event returns 0 after auparse_feed #416
Comments
Auparse was designed to handle static and dynamic event collections. The auparse_next _event is for static collections of events such as buffers or files. For dynamic event collections, meaning that it changes in real time, the auparse_feed should be used with a callback. It was designed to use a callback because it does a search to see if this completes an event and if so, immediately places it with the callback function. If this were deferred to auparse_next_event, it will duplicate this search for a completed event. Also, the feed function will do the callback as many times as it has complete events. Meaning passing in one record could unlock 5 events for the callback (note the kernel does not serialize events, auparse does). It's really more efficient to do it this way. I'd really prefer not to mix the two idioms as it will just confuse people as well as lose efficiency. Static collections can just use the loop method and dynamic uses feed + callback. |
Switching the placement of "if (au->callback)" and auparse_next_event is simple. But I'd be curious why callbacks don't work for your situation? If it's because some variables are out of scope, you can collect them up in a structure and pass it as the user_data variable to auparse_add_callback. It then gets handed to the callback function so that it's in scope. Many people don't know this and use global variables instead. |
Currently I am using My project is in C++. I have a parser class. The But becomes very problematic and messy if the static function (callback) gets called from multiple threads, unless I want to underutilize all the processor threads I have by putting a single mutex. The user data passed to the Initially I was using |
auparse was intended to allow multiple instances of parsing by having multiple copies of the auparse_state_t variable returned by auparse_init. However, using AUSOURCE_BUFFER can be problematic if you do not contain whole events in them. I don't know the source of the data that is being fed, but the kernel does not serialize the records it emits. Events can be interleaved which is one of problems auparse solves - but it needs to enough data that it can determine an event is finished. So, there is that issue. Also, I reviewed the code to make sure it can handle multi-threaded use. I found a problem in the auparse/interpret.c file with a static global variable, il. I am working up a patch to move that into the auparse_state_t struct which would make the library ready for multi-threading. It will be in the 4.0.3 release. Until then, there could be random problems with interpretations/crashes. |
Yes that is the problem I am encountering too. I haven't started fixing that yet as I was working on something else. In my case I have a collector that collects events and transmits over ZMQ. I don't want the collector to be heavy. So, I intend to collect enough to describe an events comprehensively and then transmit. Is it enough to check the I am mainly interested in syscalls. |
The problem of event completeness is really what auparse was designed to do. You shouldn't need to know all the details of how the kernel creates events to start a project. Auparse insulates you from these details. If the various threads are all from different data sources, you can instantiate multiple auparse_state_t variables by calling auparse_init for each data source. The problem would be that at some point the events need to be serialized with each other. Also, I would be open to ideas on how serialize multiple threads at the auparse_feed API. Perhaps the callback could choose from a pool of threads? |
I think a resources pool would be better than a thread pool. Parsing the feed requires state that cannot be shared by two threads simultaneously. So, a pool of auparse states would be better I guess. The entry to these states will be guarded by a counting semaphore. Usercode may have a threadpool from where they invoke auparse_feed function. That thread spawned by the usercode will either wait for semaphore or will process it on the available auparse state. I've recently designed a similar resource pool for Lua. But it is a bit more complicated due to type bindings and its in C++. My design is actually like this. I am collecting audit logs through an agent. I want to minimize the complexity of collection, because there can be many other collectors, e.g. log files, pcap etc.. Rather I want to collect and transmit with minimal processing. If I use auparse, while collecting then I have to serialize it and then transmit to the server. But the server will deserialize it anyway and the audit log is already serialized and parsable. So, I am avoiding parsing it while collecting. Rather I'd parse it on the server. I have one question. I am only interested in syscall. Is it okay if the collector first checks whether the entry is of type SYSCALL or not. If it is then it creates a bucket in the dictionary. After that, if it gets an entry having the same msg id then it puts it under the same bucket. It closes the bucket once it gets a PROCTITLE type entry. Once the bucket is closed take all the entries and send it over zmq. Once I receive it on the server I process it using auparse. There I use Is it possible to get any information about the event after the PROCTITLE has been written ? Then should I wait for few seconds more before closing the bucket ? |
Given au initialized with
auparse_init(AUSOURCE_FEED, 0)
the functionauparse_next_event
returns 0 even after passing data toauparse_feed
as shown in the example below. This happens even when there is no callback set.This happens because
consume_feed
loops over all the events unconditionally.I'd prefer a non-callback way of extracting events which is achievable by simple change
This way the usercode has the freedom to choose a non-callback based way of using
auparse_feed
method.The text was updated successfully, but these errors were encountered: