2020
2121# pylint: disable=missing-docstring
2222
23+ import string
2324import subprocess
2425import traceback
2526import unittest
2930import qubesadmin
3031import qubesadmin .app
3132
33+ QREXEC_ALLOWED_CHARS = string .ascii_letters + string .digits + "_-+."
3234
3335class TestVM (object ):
3436 def __init__ (self , name , ** kwargs ):
@@ -162,6 +164,9 @@ def __init__(self):
162164
163165 def qubesd_call (self , dest , method , arg = None , payload = None ,
164166 payload_stream = None ):
167+ if arg :
168+ assert all (c in QREXEC_ALLOWED_CHARS for c in arg ), \
169+ f"forbidden char in service arg '{ arg } "
165170 if payload_stream :
166171 payload = (payload or b'' ) + payload_stream .read ()
167172 call_key = (dest , method , arg , payload )
@@ -178,6 +183,8 @@ def qubesd_call(self, dest, method, arg=None, payload=None,
178183
179184 def run_service (self , dest , service , ** kwargs ):
180185 # pylint: disable=arguments-differ
186+ assert all (c in QREXEC_ALLOWED_CHARS for c in service ), \
187+ f"forbidden char in service '{ service } "
181188 self .service_calls .append ((dest , service , kwargs ))
182189 call_key = (dest , service )
183190 # TODO: consider it as a future extension, as a replacement for
0 commit comments