The build.py
script was created to compile, test and validate the available modules and its code readiness. This tool was meant to developers to speed up the code readiness checking and development and to be able to include the usage of the tool as part of automation processes and checks.
There are several modules needed in order to the tool to work correctly.
In order to run unit tests on a specific wazuh target, the project needs to be built with the DEBUG
and TEST
options as shown below:
make TARGET=server|agent DEBUG=1 TEST=1
Once the code is compiled and built successfully the following line should be executed:
usage: python3 build.py [-h] [-r READYTOREVIEW]
[-rc READYTOREVIEWANDCLEAN] [-m MAKE]
[-t TESTS] [-c COVERAGE] [-v VALGRIND] [--clean CLEAN] [--cppcheck CPPCHECK] [--asan ASAN] [--scheck SCHECK]
[--sformat SFORMAT] [--scanbuild SCANBUILD] [--deleteLogs DELETELOGS] [--target TARGET]
Argument | Description |
---|---|
-h , --help |
Show the help message and exit |
-r , --readytoreview |
Run all the quality checks needed to create a PR. Example: `python3 build.py -r <wazuh_modules/syscollector |
-d , --readytoreviewandclean |
Run all the quality checks needed to create a PR. Example: `python3 build.py -d <wazuh_modules/syscollector |
-m , --make |
Compile the lib. Example: `python3 build.py -m <wazuh_modules/syscollector |
-t , --tests |
Run tests (should be configured with TEST=on). Example: `python3 build.py -t <wazuh_modules/syscollector |
-c , --coverage |
Collect tests coverage and generates report. Example: `python3 build.py -c <wazuh_modules/syscollector |
-v , --valgrind |
Run valgrind on tests. Example: `python3 build.py -v <wazuh_modules/syscollector |
--clean |
Clean the lib. Example: `python3 build.py --clean <wazuh_modules/syscollector |
--cppcheck |
Run cppcheck on the code. Example: `python3 build.py --cppcheck <wazuh_modules/syscollector |
--asan |
Run ASAN on the code. Example: `python3 build.py --asan <wazuh_modules/syscollector |
--scheck |
Run AStyle on the code for checking purposes. Example: `python3 build.py --scheck <wazuh_modules/syscollector |
--sformat |
Run AStyle on the code formatting the needed files. Example: `python3 build.py --sformat <wazuh_modules/syscollector |
--scanbuild |
Run scan-build on the code. Example: python3 build.py --scanbuild <agent|server|winagent> |
--target |
This is an add-on to the ready-to-review test because this could add specific tests, by default the target is the agent. Example: python3 build.py -r --target <agent|server|winagent> |
--deleteLogs |
Clean log results to some module. Example: `python3 build.py --deleteLogs <wazuh_modules/syscollector |
Ready to review checks:
If all the checks passed it returns 0 and prints a "[RTR: PASSED]", otherwise it stops the execution of the checking on the first failure, prints the info related to the failure and returns and error code. We can use a flag like target
to run tests on Windows this runs unit tests so this works only for syscheckd at the moment.
Output Example executing the RTR tool with dbsync
module:
#> python3 build.py -r shared_modules/dbsync
<shared_modules/dbsync>=================== Running RTR checks ===================<shared_modules/dbsync>
<shared_modules/dbsync>=================== Running cppcheck ===================<shared_modules/dbsync>
[Cppcheck: PASSED]
[Cleanfolder : PASSED]
<shared_modules/dbsync>=================== Running CMake Conf ===================<shared_modules/dbsync>
[ConfigureCMake: PASSED]
<shared_modules/dbsync>=================== Compiling library ===================<shared_modules/dbsync>
shared_modules/dbsync > [make: PASSED]
<shared_modules/dbsync>=================== Running Tests ===================<shared_modules/dbsync>
[dbsyncPipelineFactory_unit_test: PASSED]
[dbengine_unit_test: PASSED]
[dbsync_unit_test: PASSED]
[fim_integration_test: PASSED]
[sqlite_unit_test: PASSED]
<shared_modules/dbsync>=================== Running Valgrind ===================<shared_modules/dbsync>
[dbsyncPipelineFactory_unit_test : PASSED]
[dbengine_unit_test : PASSED]
[dbsync_unit_test : PASSED]
[fim_integration_test : PASSED]
[sqlite_unit_test : PASSED]
<shared_modules/dbsync>=================== Running Coverage ===================<shared_modules/dbsync>
[lcov info: GENERATED]
[genhtml info: GENERATED]
Report: /root/repos/wazuh/src/shared_modules/dbsync/coverage_report/index.html
[Lines Coverage 95.1%: PASSED]
[Functions Coverage 98.0%: PASSED]
<shared_modules/dbsync>=================== Running AStyle ===================<shared_modules/dbsync>
[Cleanfolder : PASSED]
<shared_modules/dbsync>[AStyle Check: PASSED]<shared_modules/dbsync>
<shared_modules/dbsync>=================== Running ASAN ===================<shared_modules/dbsync>
[CleanInternals: PASSED]
[MakeTarget: PASSED]
[Cleanfolder : PASSED]
<shared_modules/dbsync>=================== Running CMake Conf ===================<shared_modules/dbsync>
[ConfigureCMake: PASSED]
<shared_modules/dbsync>=================== Compiling library ===================<shared_modules/dbsync>
shared_modules/dbsync > [make: PASSED]
[Cleanfolder : PASSED]
<TESTTOOL>=================== Running TEST TOOL ===================<TESTTOOL>
/root/repos/wazuh/src/shared_modules/dbsync/build/bin/dbsync_test_tool -c config.json -a snapshotsUpdate/insertData.json,snapshotsUpdate/updateWithSnapshot.json -o ./output
[TestTool: PASSED]
<TESTTOOL>=================== Running TEST TOOL ===================<TESTTOOL>
/root/repos/wazuh/src/shared_modules/dbsync/build/bin/dbsync_test_tool -c config.json -a InsertionUpdateDeleteSelect/inputSyncRowInsert.json,InsertionUpdateDeleteSelect/inputSyncRowModified.json,InsertionUpdateDeleteSelect/deleteRows.json,InsertionUpdateDeleteSelect/inputSelectRows.json -o ./output
[TestTool: PASSED]
<TESTTOOL>=================== Running TEST TOOL ===================<TESTTOOL>
/root/repos/wazuh/src/shared_modules/dbsync/build/bin/dbsync_test_tool -c config.json -a txnOperation/createTxn.json,txnOperation/inputSyncRowInsertTxn.json,txnOperation/pksGetDeletedRows.json,txnOperation/inputSyncRowModifiedTxn.json,txnOperation/closeTxn.json -o ./output
[TestTool: PASSED]
<TESTTOOL>=================== Running TEST TOOL ===================<TESTTOOL>
/root/repos/wazuh/src/shared_modules/dbsync/build/bin/dbsync_test_tool -c config.json -a txnOperation/createTxn.json,txnOperation/inputSyncRowInsertTxn.json,txnOperation/fullyGetDeletedRows.json,txnOperation/inputSyncRowModifiedTxn.json,txnOperation/closeTxn.json -o ./output
[TestTool: PASSED]
<TESTTOOL>=================== Running TEST TOOL ===================<TESTTOOL>
/root/repos/wazuh/src/shared_modules/dbsync/build/bin/dbsync_test_tool -c config.json -a triggerActions/insertDataProcesses.json,triggerActions/insertDataSocket.json,triggerActions/addTableRelationship.json,triggerActions/deleteRows.json -o ./output
[TestTool: PASSED]
<TESTTOOL>=================== Running TEST TOOL ===================<TESTTOOL>
/root/repos/wazuh/src/shared_modules/dbsync/build/bin/dbsync_test_tool -c config.json -a triggerActions/insertDataProcesses.json,triggerActions/insertDataSocket.json,triggerActions/addTableRelationship.json,triggerActions/deleteRows.json -o ./output
[TestTool: PASSED]
<shared_modules/dbsync>[ASAN: PASSED]<shared_modules/dbsync>
<shared_modules/dbsync>[RTR: PASSED]<shared_modules/dbsync>
Output Example executing the RTR tool with syscheck
module and target winagent
:
#> python3 build.py -r syscheckd --target winagent
<syscheckd>=============== Running RTR checks ===============<syscheckd>
<syscheckd>=============== Running cppcheck ===============<syscheckd>
[Cppcheck: PASSED]
<winagent>=============== Running Make Deps ===============<winagent>
[MakeDeps: PASSED]
<winagent>=============== Running Make project ==============<winagent>
[MakeTarget: PASSED]
<syscheckd>=============== Running Tests ===============<syscheckd>
[fim_db_interface_test.exe: PASSED]
[fileitem_unit_test.exe: PASSED]
[registryvalue_unit_test.exe: PASSED]
[fimdb_unit_test.exe: PASSED]
[fim_registry_interface_test.exe: PASSED]
[fim_file_interface_test.exe: PASSED]
[registrykey_unit_test.exe: PASSED]
<syscheckd>[All tests: PASSED]<syscheckd>
[Cleanfolder : PASSED]
<syscheckd>=============== Running CMake Conf ===============<syscheckd>
[ConfigureCMake: PASSED]
<syscheckd>=============== Running AStyle ===============<syscheckd>
[Cleanfolder : PASSED]
[AStyle Check: PASSED]
[CleanAll: PASSED]
[CleanExternals: PASSED]
<agent>=============== Running Make Deps ===============<agent>
[MakeDeps: PASSED]
<agent>=============== Running Make project ==============<agent>
[MakeTarget: PASSED]
[Cleanfolder : PASSED]
<syscheckd>=============== Running ASAN ===============<syscheckd>
[CleanInternals: PASSED]
<agent>=============== Running Make project ==============<agent>
[MakeTarget: PASSED]
[Cleanfolder : PASSED]
<syscheckd>=============== Running CMake Conf ===============<syscheckd>
[ConfigureCMake: PASSED]
<syscheckd>=============== Compiling library ===============<syscheckd>
[make: PASSED]
[Cleanfolder : PASSED]
<TESTTOOL>=============== Running TEST TOOL ===============<TESTTOOL>
/home/francorivero/Desktop/Wazuh_repositories/vagrant/wazuh/src/syscheckd/build/bin/fimdb_test_tool -c config.json -a FimDBTransaction/StartTransaction.json,FimDBTransaction/SyncTxnRows_1.json,FimDBTransaction/GetDeletedRows.json,FimDBTransaction/CountFiles.json,FimDBTransaction/StartTransaction.json,FimDBTransaction/SyncTxnRows_2.json,FimDBTransaction/GetDeletedRows.json,FimDBTransaction/CountFiles.json -o ./output/fileTransaction
<TESTTOOL>=============== Running TEST TOOL ===============<TESTTOOL>
/home/francorivero/Desktop/Wazuh_repositories/vagrant/wazuh/src/syscheckd/build/bin/fimdb_test_tool -c config.json -a atomicFileOperations/SyncRow_1.json,atomicFileOperations/SyncRow_2.json,atomicFileOperations/CountFiles.json,atomicFileOperations/SyncRow_3.json,atomicFileOperations/DeleteFile.json,atomicFileOperations/CountFiles.json,atomicFileOperations/GetFile.json -o ./output/AtomicOperations
[ASAN: PASSED]
<syscheckd>=============== Running TEST TOOL for Windows =====<syscheckd>
[CleanAll: PASSED]
[CleanExternals: PASSED]
<winagent>=============== Running Make Deps ===============<winagent>
[MakeDeps: PASSED]
<winagent>=============== Running Make project ==============<winagent>
[MakeTarget: PASSED]
<TESTTOOL>=============== Running TEST TOOL ===============<TESTTOOL>
WINEPATH="/usr/i686-w64-mingw32/lib;/home/francorivero/Desktop/Wazuh_repositories/vagrant/wazuh/src" WINEARCH=win64 /usr/bin/wine /home/francorivero/Desktop/Wazuh_repositories/vagrant/wazuh/src/syscheckd/build/bin/fimdb_test_tool.exe -c configWindows.json -a FimDBTransaction/StartTransactionRegistryKey.json,FimDBTransaction/SyncTxnRowsRegistryKey_1.json,FimDBTransaction/GetDeletedRows.json,FimDBTransaction/StartTransactionRegistryKey.json,FimDBTransaction/SyncTxnRowsRegistryKey_2.json,FimDBTransaction/GetDeletedRows.json -o ./output/registryKeyTransaction
<TESTTOOL>=============== Running TEST TOOL ===============<TESTTOOL>
WINEPATH="/usr/i686-w64-mingw32/lib;/home/francorivero/Desktop/Wazuh_repositories/vagrant/wazuh/src" WINEARCH=win64 /usr/bin/wine /home/francorivero/Desktop/Wazuh_repositories/vagrant/wazuh/src/syscheckd/build/bin/fimdb_test_tool.exe -c configWindows.json -a FimDBTransaction/StartTransactionRegistryData.json,FimDBTransaction/SyncTxnRowsRegistryData_1.json,FimDBTransaction/GetDeletedRows.json,FimDBTransaction/StartTransactionRegistryData.json,FimDBTransaction/SyncTxnRowsRegistryData_2.json,FimDBTransaction/GetDeletedRows.json -o ./output/registryDataTransaction
[TEST TOOL for Windows: PASSED]
[TestTool check: PASSED]
<syscheckd>[RTR: PASSED]<syscheckd>
Address sanitizer checks:
Output Example executing the ASAN tests with dbsync
module:
#> python3 build.py --asan shared_modules/dbsync
<shared_modules/dbsync>=================== Running ASAN ===================<shared_modules/dbsync>
[CleanInternals: PASSED]
[MakeTarget: PASSED]
[Cleanfolder : PASSED]
<shared_modules/dbsync>=================== Running CMake Conf ===================<shared_modules/dbsync>
[ConfigureCMake: PASSED]
<shared_modules/dbsync>=================== Compiling library ===================<shared_modules/dbsync>
shared_modules/dbsync > [make: PASSED]
[Cleanfolder : PASSED]
<TESTTOOL>=================== Running TEST TOOL ===================<TESTTOOL>
/root/repos/wazuh/src/shared_modules/dbsync/build/bin/dbsync_test_tool -c config.json -a snapshotsUpdate/insertData.json,snapshotsUpdate/updateWithSnapshot.json -o ./output
[TestTool: PASSED]
<TESTTOOL>=================== Running TEST TOOL ===================<TESTTOOL>
/root/repos/wazuh/src/shared_modules/dbsync/build/bin/dbsync_test_tool -c config.json -a InsertionUpdateDeleteSelect/inputSyncRowInsert.json,InsertionUpdateDeleteSelect/inputSyncRowModified.json,InsertionUpdateDeleteSelect/deleteRows.json,InsertionUpdateDeleteSelect/inputSelectRows.json -o ./output
[TestTool: PASSED]
<TESTTOOL>=================== Running TEST TOOL ===================<TESTTOOL>
/root/repos/wazuh/src/shared_modules/dbsync/build/bin/dbsync_test_tool -c config.json -a txnOperation/createTxn.json,txnOperation/inputSyncRowInsertTxn.json,txnOperation/pksGetDeletedRows.json,txnOperation/inputSyncRowModifiedTxn.json,txnOperation/closeTxn.json -o ./output
[TestTool: PASSED]
<TESTTOOL>=================== Running TEST TOOL ===================<TESTTOOL>
/root/repos/wazuh/src/shared_modules/dbsync/build/bin/dbsync_test_tool -c config.json -a txnOperation/createTxn.json,txnOperation/inputSyncRowInsertTxn.json,txnOperation/fullyGetDeletedRows.json,txnOperation/inputSyncRowModifiedTxn.json,txnOperation/closeTxn.json -o ./output
[TestTool: PASSED]
<TESTTOOL>=================== Running TEST TOOL ===================<TESTTOOL>
/root/repos/wazuh/src/shared_modules/dbsync/build/bin/dbsync_test_tool -c config.json -a triggerActions/insertDataProcesses.json,triggerActions/insertDataSocket.json,triggerActions/addTableRelationship.json,triggerActions/deleteRows.json -o ./output
[TestTool: PASSED]
<TESTTOOL>=================== Running TEST TOOL ===================<TESTTOOL>
/root/repos/wazuh/src/shared_modules/dbsync/build/bin/dbsync_test_tool -c config.json -a triggerActions/insertDataProcesses.json,triggerActions/insertDataSocket.json,triggerActions/addTableRelationship.json,triggerActions/deleteRows.json -o ./output
[TestTool: PASSED]
<shared_modules/dbsync>[ASAN: PASSED]<shared_modules/dbsync>
Scan-build analysis agent/server:
Scan-build analysis winagent:
agent
target:#> python3 build.py --scanbuild agent
<agent>=================== Running Scanbuild ===================<agent>
[CleanAll: PASSED]
[CleanExternals: PASSED]
[MakeDeps: PASSED]
[ScanBuild: PASSED]
<agent>[SCANBUILD: PASSED]<agent>
Output Example executing the SCANBUILD analysis with winagent
target:
#> python3 build.py --scanbuild winagent
<winagent>=================== Running Scanbuild ===================<winagent>
[CleanAll: PASSED]
[CleanExternals: PASSED]
[MakeDeps: PASSED]
[MakeTarget: PASSED]
[CleanInternals: PASSED]
[ScanBuild: PASSED]
<winagent>[SCANBUILD: PASSED]<winagent>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。