first commit
This commit is contained in:
commit
7988853b57
43 changed files with 8415 additions and 0 deletions
53
src/services/sigma/sigma_stats_service.js
Normal file
53
src/services/sigma/sigma_stats_service.js
Normal file
|
@ -0,0 +1,53 @@
|
|||
/**
|
||||
* sigma_stats_service.js
|
||||
*
|
||||
* Service for retrieving and processing Sigma rule database statistics
|
||||
* Provides aggregated statistical information about the rule database
|
||||
*/
|
||||
const logger = require('../../utils/logger');
|
||||
const { getStatsFromDatabase } = require('../../sigma_db/sigma_db_queries');
|
||||
|
||||
const { getFileName } = require('../../utils/file_utils');
|
||||
const FILE_NAME = getFileName(__filename);
|
||||
|
||||
/**
|
||||
* Get database statistics
|
||||
* Collects various statistics about the Sigma rule database
|
||||
*
|
||||
* @returns {Promise<Object>} Object with success flag and statistics or error message
|
||||
*/
|
||||
async function getSigmaStats() {
|
||||
logger.info(`${FILE_NAME}: Getting Sigma rule database statistics`);
|
||||
|
||||
try {
|
||||
// Get statistics from database query function
|
||||
const statsResult = await getStatsFromDatabase();
|
||||
|
||||
if (!statsResult.success) {
|
||||
logger.error(`${FILE_NAME}: Failed to retrieve statistics: ${statsResult.message}`);
|
||||
return {
|
||||
success: false,
|
||||
message: statsResult.message
|
||||
};
|
||||
}
|
||||
|
||||
logger.info(`${FILE_NAME}: Successfully collected database statistics`);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
stats: statsResult.stats
|
||||
};
|
||||
} catch (error) {
|
||||
logger.error(`${FILE_NAME}: Error processing statistics: ${error.message}`);
|
||||
logger.debug(`${FILE_NAME}: Error stack: ${error.stack}`);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
message: `Error processing statistics: ${error.message}`
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getSigmaStats
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue