44import json
55import logging
66import os
7- import subprocess
7+
8+ # See comment at our point of usage of subprocess on why this usage is ok
9+ import subprocess # nosec
810import sys
911from vscode_datascience_helpers .daemon .daemon_python import (
1012 error_decorator ,
@@ -53,7 +55,8 @@ def m_exec_module(self, module_name, args=[], cwd=None, env=None):
5355 from notebook import notebookapp as app
5456
5557 return {"stdout" : "." .join (list (str (v ) for v in app .version_info ))}
56- except Exception :
58+ """ We specifically don't want to bubble up an error from --version so pass exception here """
59+ except Exception : # nosec
5760 pass
5861 # kernelspec, nbconvert are subcommands of jupyter.
5962 # python -m jupyter kernelspec, python -m jupyter nbconvert,
@@ -71,9 +74,9 @@ def m_exec_module(self, module_name, args=[], cwd=None, env=None):
7174 return super ().m_exec_module (module_name , args , cwd , env )
7275
7376 def _exec_with_subprocess (self , module_name , args = [], cwd = None , env = None ):
74- # # result = subprocess.run([sys.executable, "-m"] + args, stdout=sys.stdout, stderr=sys.stderr)
75- # return self._execute_and_capture_output(lambda: subprocess.run([sys.executable, "-m", module_name] + args, stdout=sys.stdout, stderr=sys.stderr))
76- result = subprocess .run (
77+ # The usage here traced up to our execModule function on the daemon and only goes down this path for jupyter subcommands
78+ # in m_exec_module in this class if module_name == jupyter and we are in control of the args we know that we are safe here
79+ result = subprocess .run ( # nosec
7780 [sys .executable , "-m" , module_name ] + args , capture_output = True
7881 )
7982 encoding = os .getenv ("PYTHONIOENCODING" , "utf-8" )
0 commit comments