apr-research commited on
Commit
e776bd4
·
1 Parent(s): b3c44e2

Potentially encoded cmd

Browse files
Files changed (1) hide show
  1. handler.py +12 -1
handler.py CHANGED
@@ -3,6 +3,7 @@ import pty
3
  import subprocess
4
  import select
5
  import shlex
 
6
 
7
 
8
  class EndpointHandler:
@@ -46,7 +47,15 @@ class EndpointHandler:
46
  os.close(slave_fd)
47
 
48
  return output.decode()
49
-
 
 
 
 
 
 
 
 
50
  def __call__(self, data):
51
  """
52
  :param data: input data from the inference endpoint REST API
@@ -54,6 +63,8 @@ class EndpointHandler:
54
  """
55
  # get inputs
56
  command = data.pop("inputs", None)
 
 
57
  if not isinstance(command, str):
58
  return {"error": "inputs attribute is required"}
59
 
 
3
  import subprocess
4
  import select
5
  import shlex
6
+ import base64
7
 
8
 
9
  class EndpointHandler:
 
47
  os.close(slave_fd)
48
 
49
  return output.decode()
50
+
51
+ def _decode_base64(self, command):
52
+ try:
53
+ decoded_command = base64.b64decode(command).decode()
54
+ except Exception as e:
55
+ return command
56
+
57
+ return decoded_command
58
+
59
  def __call__(self, data):
60
  """
61
  :param data: input data from the inference endpoint REST API
 
63
  """
64
  # get inputs
65
  command = data.pop("inputs", None)
66
+ command = self._decode_base64(command)
67
+
68
  if not isinstance(command, str):
69
  return {"error": "inputs attribute is required"}
70