1+ provider  "elasticstack"  {
2+   kibana  {}
3+ }
4+ 
5+ #  Basic security detection rule
6+ resource  "elasticstack_kibana_security_detection_rule"  "example"  {
7+   name         =  " Suspicious Activity Detection" 
8+   type         =  " query" 
9+   query        =  " event.action:logon AND user.name:admin" 
10+   language     =  " kuery" 
11+   enabled      =  true 
12+   description  =  " Detects suspicious admin logon activities" 
13+   severity     =  " high" 
14+   risk_score   =  75 
15+   from         =  " now-6m" 
16+   to           =  " now" 
17+   interval     =  " 5m" 
18+ 
19+   author           =  " Security Team" 
20+   tags             =  " security" " authentication" " admin" 
21+   license          =  " Elastic License v2" 
22+   false_positives  =  " Legitimate admin access during maintenance windows" 
23+   references  =  
24+     " https://example.com/security-docs" 
25+     " https://example.com/admin-access-policy" 
26+   ]
27+ 
28+   note   =  " Investigate the source IP and verify if the admin access is legitimate." 
29+   setup  =  " Ensure that authentication logs are being collected and indexed." 
30+ }
31+ 
32+ #  Advanced security detection rule with custom settings
33+ resource  "elasticstack_kibana_security_detection_rule"  "advanced"  {
34+   name         =  " Advanced Threat Detection" 
35+   type         =  " query" 
36+   query        =  " process.name:powershell.exe AND process.args:*encoded*" 
37+   language     =  " kuery" 
38+   enabled      =  true 
39+   description  =  " Detects encoded PowerShell commands which may indicate malicious activity" 
40+   severity     =  " critical" 
41+   risk_score   =  90 
42+   from         =  " now-10m" 
43+   to           =  " now" 
44+   interval     =  " 2m" 
45+   max_signals  =  200 
46+   version      =  1 
47+ 
48+   index  =  
49+     " winlogbeat-*" 
50+     " logs-windows-*" 
51+   ]
52+ 
53+   author  =  
54+     " Threat Intelligence Team" 
55+     " SOC Analysts" 
56+   ]
57+ 
58+   tags  =  
59+     " windows" 
60+     " powershell" 
61+     " encoded" 
62+     " malware" 
63+     " critical" 
64+   ]
65+ 
66+   false_positives  =  
67+     " Legitimate encoded PowerShell scripts used by automation" 
68+     " Software installation scripts" 
69+   ]
70+ 
71+   references  =  
72+     " https://attack.mitre.org/techniques/T1059/001/" 
73+     " https://example.com/powershell-security-guide" 
74+   ]
75+ 
76+   license  =  " Elastic License v2" 
77+   note     =  <<- EOT 
78+     ## Investigation Steps 
79+     1. Examine the full PowerShell command line 
80+     2. Decode any base64 encoded content 
81+     3. Check the parent process that spawned PowerShell 
82+     4. Review network connections made during execution 
83+     5. Check for file system modifications 
84+   EOT 
85+ 
86+   setup  =  <<- EOT 
87+     ## Prerequisites 
88+     - Windows endpoint monitoring must be enabled 
89+     - PowerShell logging should be configured 
90+     - Sysmon or equivalent process monitoring required 
91+   EOT 
92+ }
0 commit comments