/** * sigma_details_handler.js * * Handles Sigma rule details requests from Slack commands * Processes requests for rule explanations */ const logger = require('../../utils/logger'); const { handleError } = require('../../utils/error_handler'); const { explainSigmaRule } = require('../../services/sigma/sigma_details_service'); const { processRuleDetails } = require('./sigma_action_handlers'); const FILE_NAME = 'sigma_details_handler.js'; /** * Handle the sigma-details command for Sigma rules * * @param {Object} command - The Slack command object * @param {Function} respond - Function to send response back to Slack */ const handleCommand = async (command, respond) => { try { logger.debug(`${FILE_NAME}: Processing sigma-details command: ${JSON.stringify(command.text)}`); if (!command || !command.text) { logger.warn(`${FILE_NAME}: Empty command received for sigma-details`); await respond('Invalid command. Usage: /sigma-details [id]'); return; } // Extract rule ID const ruleId = command.text.trim(); if (!ruleId) { logger.warn(`${FILE_NAME}: Missing rule ID in sigma-details command`); await respond('Invalid command: missing rule ID. Usage: /sigma-details [id]'); return; } // Inform user we're processing await respond({ text: 'Processing your request... This may take a moment.', response_type: 'ephemeral' }); // Use the shared processRuleDetails function from action handlers await processRuleDetails(ruleId, respond, false, 'in_channel'); } catch (error) { await handleError(error, `${FILE_NAME}: Details command handler`, respond, { responseType: 'ephemeral' }); } }; module.exports = { handleCommand };