Skip to content

Commit

Permalink
feat: snyk controller extension point
Browse files Browse the repository at this point in the history
Add an extension point to allow third-party plugins to interact with Snyk in
the IDE.
  • Loading branch information
cmars committed Jan 23, 2024
1 parent e363e9c commit 545bf54
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
10 changes: 10 additions & 0 deletions META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<idea-plugin>
<id>io.snyk.plugin</id>

<extensionPoints>
<extensionPoint
name="controllerLifecycleManager"
interface="io.snyk.plugin.extensionpoints.SnykControllerLifecycleManager"/>
</extensionPoints>

</idea-plugin>
20 changes: 20 additions & 0 deletions src/main/kotlin/io/snyk/plugin/extensionpoints/SnykController.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package io.snyk.plugin.extensionpoints

import com.intellij.openapi.project.Project
import io.snyk.plugin.getSnykApiService
import io.snyk.plugin.getSnykTaskQueueService
import org.apache.commons.lang3.NotImplementedException

// SnykController is used by third-party plugins to interact with the Snyk plugin.
sealed class SnykController {
// scan enqueues a scan of the project for vulnerabilities.
fun scan(project: Project) {
getSnykTaskQueueService(project)?.scan();

Check warning

Code scanning / detekt

Detects semicolons Warning

Unnecessary semicolon
}

// userId returns the current authenticated Snyk user's ID.
// If no user is authenticated, this will return null.
fun userId(): String? {
return getSnykApiService().userId;

Check warning

Code scanning / detekt

Detects semicolons Warning

Unnecessary semicolon
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.snyk.plugin.extensionpoints

// SnykControllerLifecycleManager is the extension point interface
// which other plugins can implement in order to integrate with Snyk.
interface SnykControllerLifecycleManager {

// register is called by Snyk on third-party implementations of this interface
// to give the calling plugin an instance of SnykController which can be used
// to control Snyk in the IDE.
fun register(controller: SnykController)
}

0 comments on commit 545bf54

Please sign in to comment.