Added shlex
Preventing shell injection attacks.
This commit is contained in:
@ -4,6 +4,7 @@ import qrcode
|
|||||||
import io
|
import io
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import shlex
|
||||||
import re
|
import re
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
from telebot import types
|
from telebot import types
|
||||||
@ -17,7 +18,8 @@ bot = telebot.TeleBot(API_TOKEN)
|
|||||||
|
|
||||||
def run_cli_command(command):
|
def run_cli_command(command):
|
||||||
try:
|
try:
|
||||||
result = subprocess.check_output(command, shell=True, stderr=subprocess.STDOUT)
|
args = shlex.split(command)
|
||||||
|
result = subprocess.check_output(args, stderr=subprocess.STDOUT)
|
||||||
return result.decode('utf-8').strip()
|
return result.decode('utf-8').strip()
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
return f'Error: {e.output.decode("utf-8")}'
|
return f'Error: {e.output.decode("utf-8")}'
|
||||||
|
|||||||
Reference in New Issue
Block a user