Skip to content

Commit

Permalink
chore: add changelog entry, extension point documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
cmars committed Jan 24, 2024
1 parent 41f7529 commit 5c846ae
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 1 deletion.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Snyk Changelog

## [2.6.1]
## [2.7.0]
### Added
- Snyk controller extension point

## [2.6.2]
### Fixed
- remove more intellij-specific code and configuration

Expand Down
83 changes: 83 additions & 0 deletions EXTENSIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Snyk Extensions

This plugin offers an extension point for integrating Snyk with other Jetbrains IDE Plugins.

## What is the Snyk Controller?

The Snyk Controller is, put simply, a way to control Snyk from other plugins.

## Why would I use the Snyk Controller extension?

There are a few of use cases for the Snyk controller:

### Initiating a Snyk scan

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.

### Determining whether Snyk is authenticated to a user

It might be useful to know whether the user has authenticated with Snyk; is Snyk ready to run scans?

## How do I use the extension in my plugin?

### Add a dependency on this plugin to your plugin's `plugin.xml` file.

Release >= 2.7.0 provides the extension point.

```xml
<depends>io.snyk.snyk-intellij-plugin</depends>
```

### Declare the extension

Add an extension for `io.snyk.snyk-intellij-plugin.controllerLifecycleManager` to your plugin's `plugin.xml` file.

```xml
<extensions defaultExtensionNs="io.snyk.snyk-intellij-plugin">
<controllerLifecycleManager implementation="com.example.demointellij.MySnykControllerLifecycleManager"/>
</extensions>
```

### Implement the lifecycle manager interface

The lifecycle manager will be instantiated and passed an instance of the controller when the Snyk plugin is initialized.

```kotlin
package com.example.demointellij

import io.snyk.plugin.extensions.SnykController
import io.snyk.plugin.extensions.SnykControllerLifecycleManager

class HelloWorldControllerLifecycleManager : SnykControllerLifecycleManager {
override fun register(controller: SnykController) {
Utils().getSnykControllerService().setController(controller)
}
}
```

Snyk recommends building a [service](https://plugins.jetbrains.com/docs/intellij/plugin-services.html) to receive the
controller instance and provide it to other parts of your plugin.

### Use the controller in your plugin

See [SnykController](https://github.com/snyk/snyk-intellij-plugin/blob/main/src/main/kotlin/io/snyk/plugin/extensions/SnykController.kt)
for the current Snyk methods supported.

#### Initiating a scan

```kotlin
Utils().getSnykControllerService().getController()?.scan()
```

## What compatibility guarantees are there, for consumers of this extension?

Our [semantic version](https://semver.org/) 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.

0 comments on commit 5c846ae

Please sign in to comment.