This plugin offers an extension point for integrating Snyk with other Jetbrains IDE Plugins.
The Snyk Controller is, put simply, a way to control Snyk from other plugins.
There are a few of use cases for the Snyk controller:
There may be situations in which a plugin wants to initiate a security scan, especially at the end of a workflow which introduces changes to the project source code, manifest dependencies, OCI container builds, infrastructure files, etc. -- anything Snyk can scan.
It might be useful to know whether the user has authenticated with Snyk; is Snyk ready to run scans?
Release >= 2.7.0 provides the extension point.
<depends>io.snyk.snyk-intellij-plugin</depends>
Add an extension for io.snyk.snyk-intellij-plugin.controllerManager
to your plugin's plugin.xml
file.
<extensions defaultExtensionNs="io.snyk.snyk-intellij-plugin">
<controllerManager implementation="com.example.demointellij.MySnykControllerManager"/>
</extensions>
The dependency on Snyk can also be optional:
<depends optional="true" config-file="optional/withSnyk.xml">io.snyk.snyk-intellij-plugin</depends>
Declare the controller extension in the dependency's config file, located relative to the plugin.xml
:
<!-- Contents of optional/withSnyk.xml -->
<idea-plugin>
<extensions defaultExtensionNs="io.snyk.snyk-intellij-plugin">
<controllerManager implementation="com.example.demointellij.HelloWorldControllerManager" />
</extensions>
</idea-plugin>
The manager will be instantiated and passed an instance of the controller when the Snyk plugin is initialized.
package com.example.demointellij
import io.snyk.plugin.extensions.SnykController
import io.snyk.plugin.extensions.SnykControllerManager
class HelloWorldControllerManager : SnykControllerManager {
override fun register(controller: SnykController) {
Utils().getSnykControllerService().setController(controller)
}
}
Snyk recommends building a service to receive the controller instance and provide it to other parts of your plugin.
See SnykController for the current Snyk methods supported.
Utils().getSnykControllerService().getController()?.scan()
Our semantic version releases indicate the compatibility of the extension API with respect to past releases.
With a minor version increment, new methods may be added to interfaces, but existing methods will not be removed or their prototypes changed.
With a major version increment, there are no compatibility guarantees. Snyk suggests checking the release notes, source changes, and compatibility testing before upgrading.