From 5b48f45ceb32d02015fc17b8d8b184ca315a3cdc Mon Sep 17 00:00:00 2001
From: Orion Poplawski <orion@nwra.com>
Date: Thu, 26 Aug 2021 17:18:51 -0600
Subject: [PATCH] [ZBX-18474] Properly anchor regexes

---
 templates/os/windows_agent/template_os_windows_agent.yaml | 8 ++++----
 .../template_os_windows_agent_active.yaml                 | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/templates/os/windows_agent/template_os_windows_agent.yaml b/templates/os/windows_agent/template_os_windows_agent.yaml
index d2d13a41d7..8078557486 100644
--- a/templates/os/windows_agent/template_os_windows_agent.yaml
+++ b/templates/os/windows_agent/template_os_windows_agent.yaml
@@ -539,7 +539,7 @@ zabbix_export:
           description: 'This macro is used in filesystems discovery. Can be overridden on the host or linked template level.'
         -
           macro: '{$VFS.FS.FSNAME.NOT_MATCHES}'
-          value: ^(/dev|/sys|/run|/proc|.+/shm$)
+          value: ^(?:/dev|/sys|/run|/proc|.+/shm$)
           description: 'This macro is used in filesystems discovery. Can be overridden on the host or linked template level.'
         -
           macro: '{$VFS.FS.FSTYPE.MATCHES}'
@@ -1769,15 +1769,15 @@ zabbix_export:
           description: 'This macro is used in Service discovery. Can be overridden on the host or linked template level.'
         -
           macro: '{$SERVICE.NAME.NOT_MATCHES}'
-          value: '^RemoteRegistry|MMCSS|gupdate|SysmonLog|clr_optimization_v.+|clr_optimization_v.+|sppsvc|gpsvc|Pml Driver HPZ12|Net Driver HPZ12|MapsBroker|IntelAudioService|Intel\(R\) TPM Provisioning Service|dbupdate|DoSvc$'
+          value: '^(?:RemoteRegistry|MMCSS|gupdate|SysmonLog|clr_optimization_v.+|clr_optimization_v.+|sppsvc|gpsvc|Pml Driver HPZ12|Net Driver HPZ12|MapsBroker|IntelAudioService|Intel\(R\) TPM Provisioning Service|dbupdate|DoSvc)$'
           description: 'This macro is used in Service discovery. Can be overridden on the host or linked template level.'
         -
           macro: '{$SERVICE.STARTUPNAME.MATCHES}'
-          value: '^automatic|automatic delayed$'
+          value: '^(?:automatic|automatic delayed)$'
           description: 'This macro is used in Service discovery. Can be overridden on the host or linked template level.'
         -
           macro: '{$SERVICE.STARTUPNAME.NOT_MATCHES}'
-          value: ^manual|disabled$
+          value: ^(?:manual|disabled)$
           description: 'This macro is used in Service discovery. Can be overridden on the host or linked template level.'
       valuemaps:
         -
diff --git a/templates/os/windows_agent_active/template_os_windows_agent_active.yaml b/templates/os/windows_agent_active/template_os_windows_agent_active.yaml
index 3b3e987668..e035db49c2 100644
--- a/templates/os/windows_agent_active/template_os_windows_agent_active.yaml
+++ b/templates/os/windows_agent_active/template_os_windows_agent_active.yaml
@@ -551,7 +551,7 @@ zabbix_export:
           description: 'This macro is used in filesystems discovery. Can be overridden on the host or linked template level.'
         -
           macro: '{$VFS.FS.FSNAME.NOT_MATCHES}'
-          value: ^(/dev|/sys|/run|/proc|.+/shm$)
+          value: ^(?:/dev|/sys|/run|/proc|.+/shm$)
           description: 'This macro is used in filesystems discovery. Can be overridden on the host or linked template level.'
         -
           macro: '{$VFS.FS.FSTYPE.MATCHES}'
@@ -1815,15 +1815,15 @@ zabbix_export:
           description: 'This macro is used in Service discovery. Can be overridden on the host or linked template level.'
         -
           macro: '{$SERVICE.NAME.NOT_MATCHES}'
-          value: '^RemoteRegistry|MMCSS|gupdate|SysmonLog|clr_optimization_v.+|clr_optimization_v.+|sppsvc|gpsvc|Pml Driver HPZ12|Net Driver HPZ12|MapsBroker|IntelAudioService|Intel\(R\) TPM Provisioning Service|dbupdate|DoSvc$'
+          value: '^(?:RemoteRegistry|MMCSS|gupdate|SysmonLog|clr_optimization_v.+|clr_optimization_v.+|sppsvc|gpsvc|Pml Driver HPZ12|Net Driver HPZ12|MapsBroker|IntelAudioService|Intel\(R\) TPM Provisioning Service|dbupdate|DoSvc)$'
           description: 'This macro is used in Service discovery. Can be overridden on the host or linked template level.'
         -
           macro: '{$SERVICE.STARTUPNAME.MATCHES}'
-          value: '^automatic|automatic delayed$'
+          value: '^(?:automatic|automatic delayed)$'
           description: 'This macro is used in Service discovery. Can be overridden on the host or linked template level.'
         -
           macro: '{$SERVICE.STARTUPNAME.NOT_MATCHES}'
-          value: ^manual|disabled$
+          value: ^(?:manual|disabled)$
           description: 'This macro is used in Service discovery. Can be overridden on the host or linked template level.'
       valuemaps:
         -
-- 
2.27.0

