Skip to content
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

Skip the security check for "java.home" and "java.jdt.ls.java.home" in a trusted workspace #2600

Closed
testforstephen opened this issue Jul 29, 2022 · 0 comments · Fixed by #2607
Assignees
Labels

Comments

@testforstephen
Copy link
Collaborator

When running vscode-java in a trusted workspace, it will still pop up a security check when the workspace's settings.json has configured "java.home". I think we can skip the check if it's in a trusted workspace.

image

Also, we have adopted the trusted workspace feature for the "java.jdt.ls.vmargs" setting check, and it was natural for me to apply it to other settings such as "java.jdt.ls.java.home" and "java.home".

vscode-java/src/settings.ts

Lines 212 to 236 in 5fa5fbc

const vmargs = workspace.getConfiguration().inspect('java.jdt.ls.vmargs').workspaceValue;
if (vmargs !== undefined) {
const isWorkspaceTrusted = (workspace as any).isTrusted; // keep compatibility for old engines < 1.56.0
const agentFlag = getJavaagentFlag(vmargs);
if (agentFlag !== null && (isWorkspaceTrusted === undefined || !isWorkspaceTrusted)) {
const keyVmargs = getKey(IS_WORKSPACE_VMARGS_ALLOWED, context.storagePath, vmargs);
const vmargsVerified = globalState.get(keyVmargs);
if ((vmargsVerified === undefined || vmargsVerified === null) && (workspace.workspaceFolders && isInWorkspaceFolder(agentFlag, workspace.workspaceFolders))) {
await window.showErrorMessage(`Security Warning! The java.jdt.ls.vmargs variable defined in ${env.appName} settings includes the (${agentFlag}) javagent preference. Do you allow it to be used?`, disallow, allow).then(async selection => {
if (selection === allow) {
globalState.update(keyVmargs, true);
} else if (selection === disallow) {
globalState.update(keyVmargs, false);
await workspace.getConfiguration().update('java.jdt.ls.vmargs', undefined, ConfigurationTarget.Workspace);
}
});
}
}
}
return {
javaHome,
preference
};
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant