question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Define in the user preferences a list of file hashes to be trusted when jar files are added to the classpath of jdt.ls

See original GitHub issue

[provide a description of the issue]

Environment
  • Operating System:
  • JDK version:
  • Visual Studio Code version: Che-theia
  • Java extension version:
Steps To Reproduce

When we add a jar file in the classpath like

      java.jdt.ls.vmargs: '-javaagent:/lombok.jar'

a Security Warning is popping up and this is an issue in Che the option is not persisted in the user preferences (but in the global state which is gone when starting a new workspace).

image

For security reasons, we would like to provide a list of jar files that can be trusted in the preferences. Would be something similar to https://github.com/redhat-developer/vscode-xml/blob/985705ebd603bd08ee8ca149484d3ea48841007a/docs/Preferences.md#trusted-binary-hashes

[Please attach a sample project reproducing the error] Please attach logs

Current Result
Expected Result
Additional Informations

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
rgrunbercommented, Jun 2, 2021

I think a good compromise would be what you suggested, to confirm that the path provided by javaagent corresponds to a file that is not provided by the workspace.

1reaction
rgrunbercommented, Jun 1, 2021

Just a few workaround to consider before we look at providing some kind of trusted resource store :

  1. Can you provide javaagent argument to java.jdt.ls.vmargs under user settings (not workspace settings) ?

As you’ve discovered in https://github.com/redhat-developer/vscode-java/blob/master/src/settings.ts#L141-L158 , when the workspace settings contain javaagent in java.jdt.ls.vmargs, we bring up a popup to warn the user. However, if the setting comes from the user settings, we allow it. On most VSCode instances, this would be under ${userDataDir}/User/settings.json, and ${userDataDir} usually defaults to $HOME/.config/Code/. I’m able to get javaagent accepted as an argument without any prompt using this approach. If so, you’d probably just need to figure out what corresponds to ${userDataDir} in your environment.

  1. Can you provision the contents of globalState ?

From https://github.com/redhat-developer/vscode-java/blob/master/src/settings.ts#L141-L158 , the property written to globalState to skip the security check when javaagent is defined in workspace settings, is :

key = redhat.java
value = {"java.ls.isVmargsAllowed::${workspacePath}/jdt_ws::${javaAgentFlag}":true}

where the globalState is usually the sqlite database at ${userDataDir}/User/globalStorage/state.vscdb, ${workspacePath} would be something like /tmp/code-tmp/config/User/workspaceStorage/d7f5a8f370269b38c3449ecf3ba23efb/redhat.java and ${javaAgentFlag} would be something like -javaagent:/tmp/code-tmp/lombok.jar

I’m fairly certain (2) isn’t easy to do, but (1) seems possible. If neither work, we can probably look at some kind of trustedHash setting like we do for vscode-xml.

Read more comments on GitHub >

github_iconTop Results From Across the Web

classpath of a directory inside jar - java - Stack Overflow
The below specific command is used to set the classpath for any jar files separated by semi-columns. C:> set CLASSPATH=classpath1;classpath2...
Read more >
JAR File Specification
JAR file is a file format based on the popular ZIP file format and is used for aggregating many files into one. A...
Read more >
Eclipse JDT Language Server Project | The Eclipse Foundation
The server looks for project/build descriptors in order to correctly configure the Java support (compiler level, classpath). The project import mechanism will ...
Read more >
Support to add Jar file or any other file/directory to classpath #94
classpath file absolutely necessary? I've been having issues with incorporating .jar files from an external library into my project on vscode.
Read more >
Setting Up the CLASSPATH - VMware Docs
The following table lists the dependency JAR files associated with ... in the CLASSPATH is reserved for the core Tanzu GemFire jar file, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found