Skip to content

Preventing Terminal Trust prompt #24770

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jhhcs opened this issue Sep 4, 2024 · 23 comments · Fixed by #24993
Closed

Preventing Terminal Trust prompt #24770

jhhcs opened this issue Sep 4, 2024 · 23 comments · Fixed by #24993
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug
Milestone

Comments

@jhhcs
Copy link

jhhcs commented Sep 4, 2024

System

C:\>ver
Microsoft Windows [Version 10.0.19045.4780]
C:\>code --version
1.92.2
fee1edb8d6d72a0ddff41e5f71a671c23ed924b9
x64

Description

When I open some files in an untrusted workspace, the following banner pops up:

image

Transcribed for searchability:

Do you trust the authors of the files in this folder?

Creating a terminal process requires executing code

If you don't trust the authors of these files, we do not recommend continuing as the files may be malicious. See our docs to learn more.

I would like to request the ability to disable this pop-up. To clarify, I very much want to keep the workspace untrusted and I very much want to prevent the creation of a terminal session, I just don't want to be prompted about it. I have the following settings enabled already:

{
 "security.workspace.trust.startupPrompt": "never",
 "security.workspace.trust.banner": "never",
}

but neither achieves the desired result.

In a recent session, this banner actually became a potential security risk; as I had assumed to be rid of the banner, I started typing immediately after opening the file. I happened to press Space in the exact moment that this banner popped up, confirming the default selection to trust the workspace, which was absolutely not what I intended.

@meganrogge
Copy link

we are using the workspaceTrustService here. I'd expect that to handle your configured settings properly.

https://github.com/microsoft/vscode/blob/5affce68172f0bcbcb69af1cad2418ad019468fa/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts#L1787

@jhhcs
Copy link
Author

jhhcs commented Sep 26, 2024

To reproduce, create a workspace that is not trusted. With an external file manager, create a file inside that workspace that requests a terminal to be spawned - in my case that is a Python file, but that is likely due to something the Python extension does. When that file is opened in VSCode, the above popup always appears and no setting I have tried can silence it.

@jhhcs
Copy link
Author

jhhcs commented Nov 20, 2024

Just following up on this briefly; is this recognized as an issue and reproducible? Do you need anything else from my end?

@sbatten
Copy link
Member

sbatten commented Nov 25, 2024

What is the file that is causing the terminal to show automatically on startup? How can I reproduce that?

@sbatten sbatten added the info-needed Issue requires more information from poster label Nov 25, 2024
@jhhcs
Copy link
Author

jhhcs commented Nov 27, 2024

You can reproduce this as follows. Create a folder that is not trusted by VSCode, I will assume this location:

x:\workspace

Install the Python and Pylance extensions, and add the following to your VSCode settings:

    "extensions.supportUntrustedWorkspaces": {
        "ms-python.python": {
            "supported": true,
        },
        "ms-python.vscode-pylance": {
            "supported": true,
        },
    }

Create a file named

x:\workspace\test.py

Open the folder in VSCode. Inside VSCode, open the file test.py. This should produce the prompt shown in the original post.

@sbatten
Copy link
Member

sbatten commented Dec 10, 2024

Ah, I see, you force override the Python extensions to run in an untrusted workspace. While we support you doing this, it is not a supported flow. This is a feature request on the python extensions to support untrusted workspaces and live with some features disabled. @luabud @karthiknadig

@sbatten sbatten assigned karthiknadig and luabud and unassigned lszomoru and sbatten Dec 10, 2024
@sbatten sbatten removed the info-needed Issue requires more information from poster label Dec 10, 2024
@karthiknadig
Copy link
Member

karthiknadig commented Dec 10, 2024

@sbatten Python extension already supports running in untrusted workspace to provide completions, features like code execution, Testing, REPL, etc are disabled in this mode. I think the user ask here is about the popups and notifications from core when opening untrusted workspaces.

@jhhcs
Copy link
Author

jhhcs commented Dec 10, 2024

user ask here is about the popups and notifications from core when opening untrusted workspaces

That is correct.

@karthiknadig karthiknadig assigned sbatten and unassigned karthiknadig and luabud Jan 2, 2025
@jhhcs
Copy link
Author

jhhcs commented Jan 28, 2025

Just checking in, are there any updates here? Should I do something?

@sbatten
Copy link
Member

sbatten commented Jan 31, 2025

@karthiknadig if you support running in an untrusted mode, then I don't think you should be auto-triggering any actions which require workspace trust. That seems to be the cause of the dialogs.

@karthiknadig
Copy link
Member

@jhhcs Was this something that showed up automatically, or after triggering something?

@sbatten We don't allow anything other than LS features in untrusted mode.

@jhhcs
Copy link
Author

jhhcs commented Feb 2, 2025

Dear @karthiknadig, as explained here, this happens as soon as I open a Python file.

@karthiknadig
Copy link
Member

I apologize for missing that. Moving this to Python repo for further investigation.

@karthiknadig karthiknadig transferred this issue from microsoft/vscode-remote-release Feb 2, 2025
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Feb 2, 2025
@jhhcs
Copy link
Author

jhhcs commented Mar 11, 2025

Here's my monthly check-in; do you need anything from me? =)

@jhhcs
Copy link
Author

jhhcs commented Mar 24, 2025

Hey @karthiknadig, what is the next action on this ticket? Can I assist you in any way?

@karthiknadig
Copy link
Member

karthiknadig commented Mar 26, 2025

@jhhcs We need to see what exact thing is triggering a terminal run. The next step is enabling trace logs for python and then looking at the logs to seeing what the extension tries to run. If you can please collect and share those logs.

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Mar 26, 2025
@jhhcs
Copy link
Author

jhhcs commented Apr 8, 2025

I tried my best to figure out how to enable trace logs for Python, but failed. Could you tell me what to do exactly?

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Apr 8, 2025
@karthiknadig
Copy link
Member

Use the "Developer: Set Log Level ..." command:

Image

There you can set it to "Trace" for all extensions or specifically for Python. Clicking on the ✔️ button will preserve it between loads.

Image

@jhhcs
Copy link
Author

jhhcs commented Apr 9, 2025

I am sorry for being unclear @karthiknadig, this part didn't give me so much trouble - I cannot figure out where to find the logs. They are not shown under "Output" as some web searches led me to believe and I do not know where they would be stored on disk.

@jhhcs
Copy link
Author

jhhcs commented Apr 9, 2025

Nevermind. There's a "Show Logs" command 🤦

@jhhcs
Copy link
Author

jhhcs commented Apr 9, 2025

I set the debug level to trace, cleared all the logs, opened a file and was prompted (as usual). The only log entries that were added were the following:

Window

2025-04-09 13:50:45.100 [trace] [Window] DialogService#prompt Do you trust the authors of the files in this folder?

Python Test Log

Unit tests are not supported in this environment.

Git

2025-04-09 13:49:52.965 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:49:52.972 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:49:55.084 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:49:55.092 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:49:56.891 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:49:56.901 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:50:00.940 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:50:01.222 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:50:04.979 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:50:04.988 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:50:07.122 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:50:07.134 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:50:29.103 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:50:29.121 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:50:29.950 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:50:29.957 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:50:31.270 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:50:31.277 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:50:32.230 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:50:32.247 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:50:33.038 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:50:33.045 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:50:34.183 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:50:34.189 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:50:35.171 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:50:35.178 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:50:36.579 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:50:36.606 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:50:44.522 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:04.506 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:04.512 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:05.223 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:05.228 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:06.076 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:06.083 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:06.864 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:06.881 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:07.689 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:07.696 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:08.396 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:08.403 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:09.132 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:09.148 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:09.948 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:09.956 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:10.784 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:10.792 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:11.653 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:11.672 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:13.489 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:13.495 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:15.386 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:15.393 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:17.106 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:17.121 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:32.389 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:32.396 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:33.460 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:33.468 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:34.609 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:34.615 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:35.561 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:35.568 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:52.788 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:52.798 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:56.733 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:56.740 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:58.172 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.
2025-04-09 13:51:58.180 [trace] [Model][onDidChangeVisibleTextEditors] Workspace is not trusted.

@karthiknadig
Copy link
Member

Was there anything in the Output > Python logs? It is strange that there was the test logs but not Python logs.

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Apr 14, 2025
@jhhcs
Copy link
Author

jhhcs commented Apr 15, 2025

I don't really know why I didn't get this in my previous test, but I just did it again and got a lot more logs:

Python

2025-04-15 11:58:55.740 [debug] Reading directory failed [Error: ENOENT: no such file or directory, scandir 'W:\temporary\test\.pixi\envs'
	at Object.readdirSync (node:fs:1508:26)
	at t.readdirSync (node:electron/js2c/node_init:2:13703)
	at X:\ad\.vscode\extensions\ms-python.python-2024.22.2-win32-x64\out\client\extension.js:2:625293
	at X:\ad\.vscode\extensions\ms-python.python-2024.22.2-win32-x64\out\client\extension.js:2:625473
	at Array.map (<anonymous>)
	at v.initWatchers (X:\ad\.vscode\extensions\ms-python.python-2024.22.2-win32-x64\out\client\extension.js:2:625202)
	at async v.ensureWatchersReady (X:\ad\.vscode\extensions\ms-python.python-2024.22.2-win32-x64\out\client\extension.js:2:594254)] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'scandir',
  path: 'c:\\Workspace\\temporary\\test\\.pixi\\envs'
}
2025-04-15 11:58:55.740 [warning] Dir "W:\temporary\test\.pixi\envs" is not watchable (directory does not exist)
2025-04-15 11:58:55.740 [debug] Start watching file for changes C:\Users\jhh\.conda\environments.txt
2025-04-15 11:58:55.740 [debug] Start watching: C:\Users\jhh\.conda with pattern environments.txt using VSCode API
2025-04-15 11:58:55.740 [debug] Start watching root W:\temporary\test for globs ["python.exe","*/python.exe","*/Scripts/python.exe"]
2025-04-15 11:58:55.740 [debug] Start watching: W:\temporary\test with pattern python.exe using VSCode API
2025-04-15 11:58:55.740 [debug] Start watching: W:\temporary\test with pattern */python.exe using VSCode API
2025-04-15 11:58:55.740 [debug] Start watching: W:\temporary\test with pattern */Scripts/python.exe using VSCode API
2025-04-15 11:58:55.740 [debug] VS Code was not launched from the command line
2025-04-15 11:58:55.740 [debug] Needed to validate W:\projects\dresscode-lib\venv\Scripts\python.exe with latest info
2025-04-15 11:58:55.741 [debug] Extension ms-toolsai.jupyter accessed onDidChangeEnvironments with args: undefined
2025-04-15 11:58:55.742 [debug] Extension ms-toolsai.jupyter accessed onDidEnvironmentVariablesChange with args: undefined
2025-04-15 11:58:55.742 [debug] Extension ms-toolsai.jupyter accessed onDidEnvironmentVariablesChange with args: undefined
2025-04-15 11:58:55.742 [debug] Extension ms-toolsai.jupyter accessed getEnvironmentVariables with args: undefined
2025-04-15 11:58:55.742 [debug] Extension ms-toolsai.jupyter accessed onDidChangeEnvironments with args: undefined
2025-04-15 11:58:55.743 [debug] Extension ms-toolsai.jupyter accessed onDidChangeActiveEnvironmentPath with args: undefined
2025-04-15 11:58:55.743 [debug] Extension ms-toolsai.jupyter accessed onDidChangeEnvironments with args: undefined
2025-04-15 11:58:55.774 [debug] Extension ms-python.vscode-pylance accessed onDidChangeActiveEnvironmentPath with args: undefined
2025-04-15 11:58:55.774 [debug] Extension ms-python.vscode-pylance accessed onDidEnvironmentVariablesChange with args: undefined
2025-04-15 11:58:56.152 [debug] Extension ms-python.vscode-pylance accessed getActiveEnvironmentPath with args: undefined
2025-04-15 11:58:56.152 [debug] Extension ms-python.vscode-pylance accessed getEnvironmentVariables with args: undefined
2025-04-15 11:58:56.152 [debug] Extension ms-python.vscode-pylance accessed getActiveEnvironmentPath with args: undefined
2025-04-15 11:59:06.007 [info] Starting Pylance language server.
2025-04-15 11:59:06.008 [debug] Terminal shell path 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' identified as shell 'powershell'
2025-04-15 11:59:06.008 [debug] Shell identified as powershell 

Python Language Server

2025-04-15 11:58:56.130 [info] [Info  - 11:58:56 AM] (19944) Server root directory: file:///x%3A/ad/.vscode/extensions/ms-python.vscode-pylance-2024.12.1/dist
2025-04-15 11:58:56.130 [info] [Info  - 11:58:56 AM] (19944) Pylance language server 2024.12.1 (pyright version 1.1.389, commit ce1325fc) starting
2025-04-15 11:58:56.130 [info] [Info  - 11:58:56 AM] (19944) Starting service instance "test"
2025-04-15 11:58:56.156 [info] [Info  - 11:58:56 AM] (19944) No include entries specified; assuming W:\temporary\test
2025-04-15 11:58:56.157 [info] [Info  - 11:58:56 AM] (19944) Auto-excluding **/node_modules
2025-04-15 11:58:56.157 [info] [Info  - 11:58:56 AM] (19944) Auto-excluding **/__pycache__
2025-04-15 11:58:56.157 [info] [Info  - 11:58:56 AM] (19944) Auto-excluding **/.*
2025-04-15 11:58:56.200 [info] [Info  - 11:58:56 AM] (19944) Found 1 source file
2025-04-15 11:58:56.499 [info] [Info  - 11:58:56 AM] (19944) Background analysis(1) root directory: file:///x%3A/ad/.vscode/extensions/ms-python.vscode-pylance-2024.12.1/dist
2025-04-15 11:58:56.501 [info] [Info  - 11:58:56 AM] (19944) Background analysis(1) started
2025-04-15 11:59:06.006 [info] (Client) The existing extension didn't exit within 10 seconds. New instance will start, but you might encounter issues.
2025-04-15 11:59:06.006 [info] (Client) Pylance async client (2024.12.1) started with python extension (2024.22.2)

Terminal

2025-04-15 11:58:55.484 [trace] [50447da] terminalInstance#ctor (instanceId: 1) [{"executable":"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe","ignoreConfigurationCwd":true,"hideFromUser":true,"extHostTerminalId":"d3dcbdc3-9489-49b3-b771-529f9c7e9450","isExtensionOwnedTerminal":true,"shellIntegrationEnvironmentReporting":false}]
2025-04-15 11:58:57.602 [debug] [50447da] Terminal process exit ["instanceId",1,"code",null,"processState",1]
2025-04-15 11:58:57.602 [trace] [50447da] terminalInstance#dispose (instanceId: 1) []
2025-04-15 11:58:57.604 [debug] [50447da] Starting pty host []
2025-04-15 11:58:57.604 [trace] [50447da] Renderer->PtyHost#connect: before acquirePort []
2025-04-15 11:58:57.613 [trace] [50447da] Renderer->PtyHost#connect: connection established []

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Apr 15, 2025
@karthiknadig karthiknadig added bug Issue identified by VS Code Team member as probable bug and removed triage-needed Needs assignment to the proper sub-team labels Apr 18, 2025
@karthiknadig karthiknadig added this to the April 2025 milestone Apr 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants