create NLP command for details
This commit is contained in:
parent
31d6296c6e
commit
181eade8c4
6 changed files with 348 additions and 10 deletions
78
src/lang/command_patterns.js
Normal file
78
src/lang/command_patterns.js
Normal file
|
@ -0,0 +1,78 @@
|
|||
/**
|
||||
* command_patterns.js
|
||||
*
|
||||
* Defines pattern matching rules for natural language commands
|
||||
* Each pattern includes a regex and mapping for parameter extraction
|
||||
*/
|
||||
|
||||
/**
|
||||
* Command patterns array
|
||||
* Each pattern object contains:
|
||||
* - name: A descriptive name for the pattern
|
||||
* - regex: A regular expression to match the command
|
||||
* - action: The action to perform (e.g., details, search)
|
||||
* - module: The module to use (e.g., sigma, alerts)
|
||||
* - params: Array of capturing group indices to extract parameters
|
||||
*/
|
||||
const commandPatterns = [
|
||||
// Sigma details patterns
|
||||
{
|
||||
name: 'sigma-details-direct',
|
||||
regex: /^(explain|get|show|display|details|info|about)\s+(rule|detection)\s+(from\s+)?sigma\s+(where\s+)?(id=|id\s+is\s+|with\s+id\s+)(.+)$/i,
|
||||
action: 'details',
|
||||
module: 'sigma',
|
||||
params: [6] // rule ID is in capturing group 6
|
||||
},
|
||||
{
|
||||
name: 'sigma-details-simple',
|
||||
regex: /^(details|explain)\s+(.+)$/i,
|
||||
action: 'details',
|
||||
module: 'sigma',
|
||||
params: [2] // rule ID is in capturing group 2
|
||||
},
|
||||
|
||||
// Sigma search patterns
|
||||
{
|
||||
name: 'sigma-search',
|
||||
regex: /^(search|find|look\s+for)\s+(rules|detections)?\s*(in|from)?\s*sigma\s+(for|where|with)?\s+(.+)$/i,
|
||||
action: 'search',
|
||||
module: 'sigma',
|
||||
params: [5] // search query is in capturing group 5
|
||||
},
|
||||
{
|
||||
name: 'sigma-search-simple',
|
||||
regex: /^(search|find)\s+(.+)$/i,
|
||||
action: 'search',
|
||||
module: 'sigma',
|
||||
params: [2] // search query is in capturing group 2
|
||||
},
|
||||
|
||||
// Sigma create patterns
|
||||
{
|
||||
name: 'sigma-create',
|
||||
regex: /^(create|new|add)\s+(rule|detection)\s+(in|to|for)?\s*sigma\s+(with|using)?\s+(.+)$/i,
|
||||
action: 'create',
|
||||
module: 'sigma',
|
||||
params: [5] // creation parameters in capturing group 5
|
||||
},
|
||||
|
||||
// Sigma stats patterns
|
||||
{
|
||||
name: 'sigma-stats',
|
||||
regex: /^(stats|statistics|metrics|counts)\s+(for|about|on|of)?\s*sigma$/i,
|
||||
action: 'stats',
|
||||
module: 'sigma',
|
||||
params: []
|
||||
},
|
||||
{
|
||||
name: 'sigma-stats-show',
|
||||
regex: /^(show|get|display)\s+(stats|statistics|metrics|counts)\s+(for|about|on|of)?\s*sigma$/i,
|
||||
action: 'stats',
|
||||
module: 'sigma',
|
||||
params: []
|
||||
}
|
||||
|
||||
// Additional command patterns for other modules can be added here
|
||||
];
|
||||
|
||||
module.exports = commandPatterns;
|
Loading…
Add table
Add a link
Reference in a new issue