Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions elastalert/alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import json
import logging
import os
import re
import subprocess
import sys
import time
Expand Down Expand Up @@ -895,6 +896,11 @@ def alert(self, matches):
except KeyError as e:
raise EAException("Error formatting command: %s" % (e))

# Validate command arguments
for command_arg in command:
if not re.match(r'^[a-zA-Z0-9_\-./\\]+$', command_arg):
raise EAException("Invalid command argument: %s" % (command_arg))

# Run command and pipe data
try:
subp = subprocess.Popen(command, stdin=subprocess.PIPE, shell=self.shell)
Expand Down