wazuh / qa-system-framework

GNU General Public License v2.0
1 stars 3 forks source link

Add file regex monitoring tool #16

Closed jmv74211 closed 1 year ago

jmv74211 commented 1 year ago
Related issue
#9

This PR adds a new tool called FileRegexMonitor to monitor files and check if the new content matches the criteria defined in a callback.

In addition, several tests have been added to check the expected behavior.

Tool design

The FileRegexMonitor tool is designed to monitor files to see if new lines added to trigger a specific callback. This is useful to see if expected logs are generated on specific files.

This tool will consist of the following parameters:

The operation will be very simple, since we will only have to create the object of the class to start directly the monitoring. For example:

FileRegexMonitor(monitored_file, callback, timeout ...)

From here the monitoring will start. If the callback is not triggered with the expected result, an exception will be generated:

wazuh_qa_framework.generic_modules.exceptions.exceptions.TimeoutError: Events from file.log did not match with the callback
Rebits commented 1 year ago

Has been proposed preliminary SRS. Using that for development acceptance we should conclude that some requirements are not fulfilled:

Functional requirements

Nonfunctional requirements

3.2 Reliability The library should be reliable and provide accurate results for regex pattern matching, sequence detection, and group extraction. Also, it should be error resistant, handling the case of unexpected inputs on the file.

jmv74211 commented 1 year ago

According to the proposals made by Victor here, the following changes have been implemented:

All these new features have been tested with unit tests that are attached in this PR.