The full upstream README, mirrored here for reference. Install config, tool schemas, adoption signals, and an original overview live on the Snyk Ls listing page.
The language server follows the Language Server Protocol and integrates with Snyk Open Source, Snyk Infrastructure as Code, Snyk Code, and Snyk Secrets. For Open Source and IaC it uses the Snyk CLI as a data provider; Snyk Code uses the Snyk Code API; Secrets scanning uses the CLI where applicable.
Right now the language server supports the following actions:
$/progress
$/cancelRequest
textDocument/publishDiagnostics
types.PublishDiagnosticsParamswindow/logMessage
window/showMessage
SDKs callback to retrieve configured SDKs from the client
workspace/snyk.sdkstypes.WorkspaceFolderConfiguration Notification (protocol v25+)
$/snyk.configurationtypes.LspConfigurationParamchanged: true for PATCH semantics: {"snyk_oss_enabled": {"value": true, "changed": true}}Custom Publish Diagnostics Notification
$/snyk.publishDiagnostics316types.PublishDiagnosticsParamsAuthentication Notification
$/snyk.hasAuthenticatedtypes.AuthenticationParamsCLI Path Notification
$/snyk.isAvailableClitypes.SnykIsAvailableCliTrusted Folder Notification
$/snyk.addTrustedFolderstypes.SnykTrustedFoldersParamsScan Notification
$/snyk.scantypes.ScanParamsSummary Panel Status Notification
$/snyk.scanSummarytypes.ScanSummaryRegister MCP Notification
$/snyk.registerMcptypes.SnykRegisterMcpParamsNavigateToRangeCommand navigates the client to the given range
snyk.navigateToRangepath, RangeWorkspaceScanCommand triggers a scan of all workspace folders
snyk.workspace.scanWorkspaceFolderScanCommand triggers a scan of the given workspace folder
snyk.workspaceFolder.scanpathOpenBrowserCommand opens the given URL in the default browser
snyk.openBrowserURLLoginCommand triggers the login process
snyk.login[authMethod, endpoint, insecure] — e.g. ["oauth", "https://api.snyk.io", false] (see configuration HTML bridge); omitted args use current settingsCopyAuthLinkCommand copies the authentication URL to the clipboard
snyk.copyAuthLinkLogoutCommand triggers the logout process
snyk.logoutTrustWorkspaceFoldersCommand checks for trusted workspace folders and asks for trust if necessary
snyk.trustWorkspaceFoldersOpenLearnLesson opens the given lesson on the Snyk Learn website
snyk.openLearnLessonrule stringecosystem stringcwes string (comma separated), e.g. CWE-79,CWE-89cves string (comma separated), e.g. CVE-2018-11776,CVE-2018-11784issueType intGetLearnSession returns the given lesson on the Snyk Learn website
snyk.getLearnLessonrule stringecosystem stringcwes string (comma separated), e.g. CWE-79,CWE-89cves string (comma separated), e.g. CVE-2018-11776,CVE-2018-11784issueType intSettingsSastEnabled triggers the api call to check if Snyk Code is enabled
snyk.getSettingsSastEnabled*sast_contract.SastResponse or, or an error and false if an error occurredGetActiveUser triggers the api call to get the active logged in user or an error if not logged in
snyk.getActiveUserCode Fix Command triggers an autofix and applies the changes of the first suggestion
snyk.code.fixcodeActionId stringAffectedFilePath stringrange RangeCode Fix Diffs allows to retrieve the diffs for autofix suggestions
snyk.code.fixDiffsCode Fix Apply Edit Command triggers an autofix and applies the changes of the first suggestion
snyk.code.fixApplyEditfixId stringFeature Flag Status Command triggers the api call to check if a feature flag is enabled
snyk.getFeatureFlagStatusfeatureFlagType stringClear Cache Clears either persisted or inMemory Cache or both.
snyk.clearCachefolderUri string,cacheType persisted or inMemoryGenerate Issue Description Generates issue description in HTML.
snyk.generateIssueDescriptionissueId stringConfiguration Dialog Opens the configuration dialog with all Snyk settings.
snyk.workspace.configurationConnectivity Check Performs comprehensive connectivity diagnostics including network checks, proxy detection, authentication, and organization access.
snyk.diagnostics.checkConnectivityDirectory Diagnostics Performs directory diagnostics for Snyk-used directories, checking existence, writability, and CLI binaries.
snyk.diagnostics.checkDirectoriesThe release workflow stores the generated executables, so that they can be downloaded here. Just select the release you want the build artefacts from and download the zip file attached to it. Currently, executables for Windows, macOS and Linux are generated.
The currently published binary can be retrieved with this bash script, please keep in mind that the protocol version is part of the download link and can change to force plugin / language server synchronization. For further information please see CONTRIBUTING.md.
GOPATH and GOROOT if neededgo get ./... to download all dependenciesmake build && make install to produce a snyk-ls binary-c <FILE> allows to specify a config file to load before all others
-f <FILE> allows you to specify a log file instead of logging to the console
-l <LOGLEVEL> <allows to specify the log level (trace, debug, info, warn, error, fatal). The default log
level is info. This can be overruled by setting the env variable SNYK_LOG_LEVEL,
e.g. export SNYK_LOG_LEVEL=debug
-licenses (running standalone) displays the licenses used by
Language Server
--licenses (running within Snyk CLI)
-o <FORMAT> allows to specify the output format (md or html) for issues
-v prints the version of the Language Server
As part of the Initialize message,
initializationOptions is unmarshaled into types.InitializationOptions (internal/types/lsp.go).
Machine settings use pflag canonical names as map keys, each value is a ConfigSetting (value, optional changed, etc.). Only entries with changed: true are applied during initialize (IDE defaults must not wipe LDX-sync or GAF defaults).
Init-only metadata (same JSON object, top-level fields): requiredProtocolVersion, deviceId, integrationName, integrationVersion, osPlatform, osArch, runtimeName, runtimeVersion, hoverVerbosity, outputFormat, path, trustedFolders.
Example shape:
Registered flag names and precedence rules are documented in docs/configuration.md.
Runtime updates use workspace/didChangeConfiguration with the same payload envelope: LSP settings is an LspConfigurationParam whose fields are settings (map), folderConfigs, and optional trustedFolders — see types.DidChangeConfigurationParams in internal/types/lsp.go.
As part of examining the codebase for vulnerabilities, Snyk may automatically execute code on your computer to obtain additional data for analysis. For example, this includes invoking the package manager (e.g., pip, gradle, maven, yarn, npm, etc.) to get dependency information for Snyk Open Source. Invoking these programs on untrusted code that has malicious configurations may expose your system to malicious code execution and exploits.
To safeguard from using the language server on untrusted folders, our language server will ask for folder trust before running scans against these folders. When in doubt, do not grant trust.
The trust feature is enabled by default. When a folder is trusted, all sub-folders are also trusted. After a folder
is trusted, Snyk Language Server notifies the Language Server Client with the custom $/snyk.addTrustedFolders
notification,
which contains a list of currently trusted folder paths. Based on this, a client can then implement logic to intercept
this notification and persist the decision and trust in the IDE or Editor storage mechanism.
Trust dialogs can be disabled by setting enableTrustedFoldersFeature to false in the initialization options. This
will disable all trust prompts and checks.
An initial set of trusted folders can be provided by setting trustedFolders to an array of paths in the
initializationOptions. These folders will be trusted on startup and will not prompt the user to trust them.
Snyk LS and Snyk CLI support and need certain environment variables to function:
HTTP_PROXY, HTTPS_PROXY and NO_PROXY to define the http proxy to be usedJAVA_HOME to analyse Java JVM-based projects via Snyk CLIPATH to find maven when analysing Maven projects, to find python, etcTo automatically add these variables to the environment, Snyk LS searches for the following files, with the order
determining precedence. If the executable is not called from an already configured environment (e.g. via
zsh -i -c 'snyk-ls'), you can also specify config file with the -c command line flag for setting the above mentioned
variables. Snyk LS reads the following files in the given precedence and order, not overwriting the already loaded
variables.
Any lines that contain an environment variable in the format
VARIABLENAME=VARIABLEVALUE are added automatically to the environment if not already existent. This adheres to the
dotenv format. In case of .profile, .zshrc, etc., if a variable is directly exported e.g. via
export VARIABLENAME=VARIABLEVALUE, it is not loaded. The export would need to be split of and be in its own line, e.g
The PATH variable is treated differently than all other variables, as it is an aggregate of all PATH variables found in
the files and in the environment. Also, the current working directory . is automatically added to the path, so a
download of the Snyk CLI into the current working directory by an LSP client would yield a found Snyk CLI for the
Language Server.
In addition to configuring variables via config files, Snyk LS adds the following directories to the path on linux and macOS:
If no JAVA_HOME is set, it automatically searches for a java executable first in path, then in the following directories and adds the parent directory of its parent as JAVA_HOME. The following directories are recursively searched:
The same directories are searched for a maven executable and the parent directory is added to the path.
To find the automatically managed Snyk CLI,
the XDG Data Home
and PATH path are automatically scanned for the OS-dependent file, e.g. snyk-macos on macOS,
snyk-linux on Linux and snyk-win.exe on Windows, and the first path where it is found is added to the environment.
It is later used for all functionality that depends on the CLI.
If you want to have the environment variables available system-wide, you would need to add the variables
to /etc/environment or on macOS to /etc/launchd.conf or set them via launchctl in a shell script. The former two
locations are automatically read by snyk lsp. On Windows, a user variable can be defined via the UI for the user or
system-wide. In a file like ~/.profile it would like this:
The Snyk LS authentication flow happens automatically, unless disabled in configuration, and is as follows. When Snyk Language Server starts, it:
oauth, it authenticates via OAuth2.
This opens a browser window.oauth, it tries to retrieve a token using the Snyk CLI token authentication.snyk.copyAuthLink). Note that there is a requirement to have xsel or xclip installed for Linux/Unix users
for this feature.After successfull authentication in the web browser, the Snyk Language Server automatically retrieves the Snyk authentication credentials and uses them for further requests.
If you have any issues with running pact, please extend your PATH env. For example:
The output should look like this (it is running against the Snyk Code API and using the real CLI):
You can test github actions locally using act.